jakmeier / nuts Goto Github PK
View Code? Open in Web Editor NEWNuts is a Rust library that offers a simple publish-subscribe API, featuring decoupled creation of the publisher and the subscriber.
Nuts is a Rust library that offers a simple publish-subscribe API, featuring decoupled creation of the publisher and the subscriber.
Right now, nuts only works in a single thread. All data is stored in the thread-local storage object NUT
. If there are multiple threads (non-web) then there will be multiple such nuts that are completely oblivious of each other.
The idea to be captured by this issue is that there could be multiple nuts that communicate with each other and the work split between them. Activities in different domains could live in different nuts. Messages would be forwarded to all nuts, but the state stored in domains could be kept in a single nut (= single thread).
Once this works on a non-web target, the feature can be extended to work on the web too, using web workers that communicate with the browser API's message passing. This would allow to have easy multi-threading in WASM, even without browser support for SharedArrayBuffer and WebAssembly threads.
Allow subscriptions without an activity.
With the current API, a subscription can only be created on an activity. This sometimes forces programmers to create a dummy activity to react on a specific message.
Example:
let dummy = nuts::new_activity(());
dummy.subscribe(|_: &mut(), msg: &Message| { /*...*/ });
nuts::subscribe(|msg: &Message| { /*...*/ });
Also feasible to add:
nuts::subscribe_domained(&MyDomain::DomainA, |domain, msg: &Message| { /*...*/ });
Nuts sequentially schedules jobs that are activated by published messages. It is essentially implementing an event loop.
When Nuts is used in the browser, it could potentially use the postMessage() function to schedule tasks on the native event loop.
Before merging a potential implementation, it would be good to assess the performance and size difference.
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.