Opifex
Opifex is a Latin word meaning artisan or manufacturer and referring to
a worker who created something. This crate defines a Worker<Mode> struct
that, like the web worker interface, represents a task which can communicate
back to its creator and that is able to receive messages from it.
Quick Start
Opifex usage is very simple and intuitive.
Suppose we need to implement a simple task: adds two integer numbers, let
say a and b. We can create a simple struct:
This struct will be the message we'll send to the following Adder task:
Having such a task, and wanting to receive its results we can simply spawn a worker with:
let adder_worker = spawn;
In the same way we can implement a Response task and add it as a subscriber to events generated in the Adder task. To do this we use the function on_message:
let response_worker = adder_worker.on_message;
Now we can send Sum messages to the Adder task with:
if let Err = adder_worker.post_message.await
The full example can be found in examples folder.