All Projects → BVE-Reborn → switchyard

BVE-Reborn / switchyard

Licence: Apache-2.0 and 2 other licenses found Licenses found Apache-2.0 LICENSE.APACHE MIT LICENSE.MIT Zlib LICENSE.ZLIB
Real-time compute-focused async executor with job pools, thread-local data, and priorities.

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to switchyard

async-await-codemod
Codemod script for migrating promise-based functions to use async/await syntax
Stars: ✭ 22 (-52.17%)
Mutual labels:  async-await
haxe-concurrent
A haxelib for basic platform-agnostic concurrency support
Stars: ✭ 69 (+50%)
Mutual labels:  executor
is-async-function
Is this a native `async function`?
Stars: ✭ 17 (-63.04%)
Mutual labels:  async-await
conquerant
lightweight async/await for Clojure
Stars: ✭ 31 (-32.61%)
Mutual labels:  async-await
Mvvm
MVVM helpers, including calculated properties and asynchronous notification tasks.
Stars: ✭ 129 (+180.43%)
Mutual labels:  async-await
Mystral
Mystral (pronounced "ˈMistrəl") is an efficient library to deal with relational databases quickly.
Stars: ✭ 13 (-71.74%)
Mutual labels:  executor
is-async-supported
Check if async/await is available natively
Stars: ✭ 16 (-65.22%)
Mutual labels:  async-await
AsyncVoid
Project related to the site's posts about async void.
Stars: ✭ 32 (-30.43%)
Mutual labels:  async-await
of
🍬 Promise wrapper with sugar 🍬
Stars: ✭ 13 (-71.74%)
Mutual labels:  async-await
crontab
cron expression parser and executor for dotnet core.
Stars: ✭ 13 (-71.74%)
Mutual labels:  executor
async-preloader
Assets preloader using ES2017 async/await and fetch.
Stars: ✭ 44 (-4.35%)
Mutual labels:  async-await
tomodachi
💻 Microservice library / framework using Python's asyncio event loop with full support for HTTP + WebSockets, AWS SNS+SQS, RabbitMQ / AMQP, middleware, etc. Extendable for GraphQL, protobuf, gRPC, among other technologies.
Stars: ✭ 170 (+269.57%)
Mutual labels:  async-await
retryx
Promise-based retry workflow library.
Stars: ✭ 21 (-54.35%)
Mutual labels:  async-await
eslint-config-marine
🐬 Typescript ESLint shareable config
Stars: ✭ 16 (-65.22%)
Mutual labels:  async-await
await-lock
Mutex locks for async functions
Stars: ✭ 66 (+43.48%)
Mutual labels:  async-await
tempdb
Redis-backed ephemeral key-value store for Node
Stars: ✭ 30 (-34.78%)
Mutual labels:  async-await
Swift-Async-Await-Experiments
Experiments with Swift's new async/await feature (SE 0296)
Stars: ✭ 17 (-63.04%)
Mutual labels:  async-await
aioflask
Flask running on asyncio!
Stars: ✭ 192 (+317.39%)
Mutual labels:  async-await
game-executor
采用Reactor模式,注册readycreate, readyfinish事件到更新服务UpdateService,通过处理后进行模型缓存,然后将消息转化为 dispatchThread消息分配模型需要的create, update, finish的事件进行单线程循环调度 。调度过程使用了系统预置锁模型,来进行多线程唤醒机制,将所有的update循环检测进行多 线程调度,多线程更新服务使用future-listener机制,在完成调度后,根据模型状态,如果模型存活重新将消息转化为update 事件注册到dispatchThread消息分配模型进行循环处理。如果模型死亡将消息转化为readyfinish事件注册到更新服务UpdateServic进行销毁 。这个系统实现了模型自动缓存,多…
Stars: ✭ 28 (-39.13%)
Mutual labels:  executor
asyncexpert-course
Materials for Async Expert online course
Stars: ✭ 77 (+67.39%)
Mutual labels:  async-await

switchyard

GitHub Workflow Status Crates.io Documentation License

Real-time compute-focused async executor with job pools, thread-local data, and priorities.

Example

use switchyard::Switchyard;
use switchyard::threads::{thread_info, one_to_one};
// Create a new switchyard without thread local data
let yard = Switchyard::new(one_to_one(thread_info(), Some("thread-name")), ||()).unwrap();

// Spawn a task on priority 10 and get a JoinHandle
let handle = yard.spawn(10, async move { 5 + 5 });
// Spawn a lower priority task
let handle2 = yard.spawn(0, async move { 2 + 2 });

// Wait on the results
assert_eq!(handle.await + handle2.await, 14);

How Switchyard is Different

Switchyard is different from other existing async executors, focusing on situations where precise control of threads and execution order is needed. One such situation is using task parallelism to parallelize a compute workload.

Priorites

Each task has a priority and tasks are ran in order from high priority to low priority.

// Spawn task with lowest priority.
yard.spawn(0, async move { /* ... */ });
// Spawn task with higher priority. If both tasks are waiting, this one will run first.
yard.spawn(10, async move { /* ... */ });

Thread Local Data

Each yard has some thread local data that can be accessed using spawn_local. Both the thread local data and the future generated by the async function passed to spawn_local may be !Send and !Sync. The future will only be resumed on the thread that created it.

If the data is Send, then you can call access_per_thread_data to get a vector of mutable references to all thread's data. See it's documentation for more information.

// Create yard with thread local data. The data is !Sync.
let yard = Switchyard::new(one_to_one(thread_info(), Some("thread-name")), || Cell::new(42)).unwrap();

// Spawn task that uses thread local data. Each running thread will get their own copy.
yard.spawn_local(0, |data| async move { data.set(10) });

MSRV

1.51

Future MSRV bumps will be breaking changes.

License: MIT OR Apache-2.0 OR Zlib

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].