bastion-rs / agnostik Goto Github PK
View Code? Open in Web Editor NEWExecutor Agnostic Runtime that can run your futures with your favourite Executor
Home Page: https://docs.rs/agnostik
License: Apache License 2.0
Executor Agnostic Runtime that can run your futures with your favourite Executor
Home Page: https://docs.rs/agnostik
License: Apache License 2.0
agnostik/src/executor/tokio.rs
Line 34 in 16184b4
which causes a panic if you do something like:
use agnostik::prelude::*;
use tokio::runtime::Runtime;
fn main() {
// see tokio docs for more methods to create a runtime
let runtime = Runtime::new().expect("Failed to create a runtime"); // 1
let runtime = Agnostik::tokio_with_runtime(runtime); // 2
let result = runtime.spawn(async { 1337 });
let result = runtime.block_on(result);
assert_eq!(result, 1337);
}
(this is the code example from the agnostik docs)
My "fix" for this problem requires that the runtime is wrapped in an Arc
that is cloned on each spawn
, to prevent deadlocking on spawn
calls inside of block_on
. This isn't that ideal...
Also there is no way to use the current runtime in TokioExecutor::spawn_local
.
Stopping exposing all the spawn
fns, but block_on
on the Executor
could be better?
Or even removing the AgnostikExecutor
& LocalAgnostikExecutor
traits all together and just exposing a minimal set of apis through the "global" spawn
etc fns? The excutor traits are just wrappers over the runtimes "global" spawn
fns anyway. If there is a need for someone to start a custom runtime, then they could just use the block_on
fn on tokios runtime directly (and there is no support in agnostik to change the runtime of the other async executors). This would prevent users from implementing their own custom executors and passing those a generic argument through their application (or an extension in agnostik to support custom executors in global spawn fns), see #4
What do you think?
There should be a feature runtime_wasm
which enables to use agnostik in a wasm environment.
Currently, users are not able to implement the AgnostikExecutor
trait for their own executors, because it's impossible to create an instance of the JoinHandle
struct.
There should be a way to create a JoinHandle from a Future, which represents the Joinhandle.
Is it possible to push to crates.io ? I need tokio 1.x support.
Thanks
Create a CI build matrix for all major oses and all included executors in the Cargo.toml
file as a feature.
There should be a trait called LocalAgnostikExecutor
that extends AgnostikExecutor
but adds a span_local
method.
i'm a bit unsure if this is a temporary nightly issue, or something for us to be aware of coming up. Anyhow, thought i'd like people know.
error[E0596]: cannot borrow data in a dereference of core::pin::Pin<&mut join_handle::JoinHandle<R>>
as mutable
##[error] --> src/join_handle.rs:54:39
BastionExecutor
etc. should have debug impls + docs.
Would be really cool to get attribute macros that just call agnostik::block_on(async { #body })
.
Since async / await is available in no_std environment now, agnostik should add a no_std runtime.
I'm not sure if it should implement an own no_std executor or using an already existing crate.
When I run use agnostik::spawn
to spawn a task with the Smol executor feature, the task is not actually running unless I await the join handle.
I expected that the task should spawned in the "background" so to speak so I could continue executing other async code while it runs. Smol accomplishes this by detach()
-ing the task, but then you can't await on it after that so that seems like it breaks the agnostik::JoinHandle
. ๐ค Not sure how we want to handle that.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.