Skip to content

Commit

Permalink
fix(madsim-tokio): add try_current (#224)
Browse files Browse the repository at this point in the history
* add try_current

* bump madsim-tokio version to 0.2.29
  • Loading branch information
kwannoel authored Aug 9, 2024
1 parent 0b7fd2c commit ea9dabd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion madsim-tokio/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "madsim-tokio"
version = "0.2.28"
version = "0.2.29"
edition = "2021"
authors = ["Runji Wang <[email protected]>"]
description = "The `tokio` simulator on madsim."
Expand Down
8 changes: 7 additions & 1 deletion madsim-tokio/src/sim/runtime.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use madsim::task::{AbortHandle, JoinHandle};
use spin::Mutex;
use std::{future::Future, io};
use tokio::runtime::TryCurrentError;

/// Builds Tokio Runtime with custom configuration values.
pub struct Builder {}
Expand Down Expand Up @@ -118,10 +119,15 @@ pub struct Handle;

impl Handle {
/// Returns a handle to the current runtime.
pub fn current() -> Handle {
pub fn current() -> Self {
Handle
}

/// Returns a handle to the current runtime.
pub fn try_current() -> Result<Self, TryCurrentError> {
Ok(Handle)
}

/// Enters the runtime context.
///
/// FIXME: This is currently a no-op.
Expand Down

0 comments on commit ea9dabd

Please sign in to comment.