Skip to content

Commit 9b30a84

Browse files
authored
API to check whether we are inside a simulation (#258)
1 parent 8c8330b commit 9b30a84

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@ 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+
World::try_current(|_| ()).is_ok()
246+
}
247+
243248
/// Returns how long the currently executing host has been executing for in
244249
/// virtual time.
245250
///

0 commit comments

Comments
 (0)