Skip to content

Commit 1ddfdd8

Browse files
committed
API to check whether we are inside a simulation
1 parent af06e81 commit 1ddfdd8

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,13 @@ pub(crate) fn for_pairs(a: &Vec<IpAddr>, b: &Vec<IpAddr>, mut f: impl FnMut(IpAd
240240
}
241241
}
242242

243+
/// Returns whether the caller is in a simulation context.
244+
pub fn in_simulation() -> bool {
245+
let result = &mut false;
246+
World::current_if_set(|_| *result = true);
247+
*result
248+
}
249+
243250
/// Returns how long the currently executing host has been executing for in
244251
/// virtual time.
245252
///

0 commit comments

Comments
 (0)