Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime agnostic #1

Closed
Miaxos opened this issue Feb 16, 2024 · 4 comments
Closed

Runtime agnostic #1

Miaxos opened this issue Feb 16, 2024 · 4 comments
Assignees

Comments

@Miaxos
Copy link

Miaxos commented Feb 16, 2024

Would you allow some work over a PR to have an agnostic runtime?

It would be helpful to be able to write test that could be run against multiple runtime. (Especially in openraft which use this library to execute integration test).

I would love to be able to run integration tests with a monoio here: databendlabs/openraft#1011

@drmingdrmer
Copy link
Owner

Hmm... It's feasible.

@drmingdrmer
Copy link
Owner

with features = ["monoio"], monoio support is added in 0.3.3:

#[async_entry::test]
async fn test_monoio_spawn() {
let m = Arc::new(Mutex::new(0u64));
let m2 = m.clone();
let join_handle = monoio::spawn(async move {
let mut v = m2.lock().unwrap();
*v = 5;
});
join_handle.await;
let got = *(m.lock().unwrap());
assert_eq!(got, 5);
}
}

Feel free to reopen this issue if there are any problem.

@drmingdrmer
Copy link
Owner

drmingdrmer commented Feb 19, 2024

Refer to: https://docs.rs/async-entry/latest/async_entry/attr.test.html#usage-for-monoio-runtime

Marks async function to be executed by async runtime, suitable to test environment

@Miaxos
Copy link
Author

Miaxos commented Feb 19, 2024

You're really fast, I was going to take some time to do it this week, I'm back from my weekend & it's all done already! Nice, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants