Skip to content

Commit

Permalink
Added more comments for the shared runtime behaviour which will also …
Browse files Browse the repository at this point in the history
…trigger the integration tests again
  • Loading branch information
john-sharratt authored and theduke committed Mar 21, 2023
1 parent 87f3a48 commit c7d2533
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/wasi/src/runtime/task_manager/tokio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ use super::{SpawnType, VirtualTaskManager};
#[derive(Clone, Debug)]
pub struct TokioTaskManager(Handle);

/// This holds the currently set shared runtime which should be accessed via
/// TokioTaskManager::shared() and/or set via TokioTaskManager::set_shared()
static GLOBAL_RUNTIME: Mutex<Option<(Arc<tokio::runtime::Runtime>, Handle)>> = Mutex::new(None);

impl TokioTaskManager {
Expand All @@ -30,8 +32,11 @@ impl TokioTaskManager {
self.0.clone()
}

/// Allows the system to set the shared runtime that will be used by other
/// processes within Wasmer
/// Allows the caller to set the shared runtime that will be used by other
/// async processes within Wasmer
///
/// The shared runtime must be set before it is used and can only be set once
/// otherwise this call will fail with an error.
pub fn set_shared(rt: Arc<tokio::runtime::Runtime>) -> Result<(), anyhow::Error> {
let mut guard = GLOBAL_RUNTIME.lock().unwrap();
if guard.is_some() {
Expand Down

0 comments on commit c7d2533

Please sign in to comment.