The problem at hand
Consider an event loop, defined as follows:
let = channel;
spawn;
Now, imagine a system library that can watch for keyboard events, with the following signature:
How can we interact with this library? Well, with Sender
, the only way is to fire another
thread, as follows:
let = channel;
let tx = tx.clone; // That's the tx for my event loop, see above.
spawn
Wouldn't it be nicer and more resource-efficient if we could write the following and have it work without spawning a thread?
third_party_library.register_watch;
Now, let's assume that the situation is slightly more complicated and that our system needs to handle several keyboards. Now, we need to label each keyboard with a unique key.
With Sender
, the only solution is to fire one thread per keyboard, i.e.
let key = ...;
let = channel;
let tx = tx.clone; // That's the tx for my event loop, see above.
spawn
Wouldn't it be nicer and more resource-efficient if we could write the following and have it work without spawning a thread?
let key = ...;
third_party_library.register_watch;
This crate is designed to make the nicer and more resource-efficient strategy possible.