Replace the sequential counting (which might be exhausted) by an address
of an object (in a box, so it doesn't change). This is also a unique, so
it is acceptable ID.
Run multiple loops (both in parallel and sequentially) to make sure
broadcasting to multiple of them works and we work even after the
initial loop has gone away.
Add the driver task, connecting the signal handler wakeups to the
wakeups of of the streams.
It is a prototype-quality code, a lot of cleanups and similar is needed.
Which is just a wrapper around the futures::sync::mpsc. The sender is in
a global registry.
The part that connects the wakeups to the senders in the registry
doesn't yet exist.
Register the signal handler that wakes up someone through a self-pipe.
That someone doesn't yet exist, though.
Some dependencies (nix, lazy_static) added to speed up the prototyping
process. They are likely to be dropped in some future commits.
Some features (eg. preserving the previous signal handlers) are still
missing.
## Motivation
`tokio_threadpool::ThreadPool::spawn` has no return value.
## Solution
Add `ThreadPool::spawn_handle` which calls
`futures::sync::oneshot::spawn` to return a future represents the return
value.
This patch refactors `length_delimited` to be implemented as a `Codec` and
use the default `Framed` wrapper types.
The original implementation did not do this in order to support vectored writes in the
write half. However, this implementation would be more efficient with small frames anyway.
If vectored writes are to be explored in the future, then it should be done holistically.
Signed-off-by: Eliza Weisman <[email protected]>
Previously, every call to `current_thread::Handle::spawn` would go
through a `mpsc` channel. This is unnecessary when the `Handle` is still
on the same thread as the current thread executor. This patch fixes that
by storing the `ThreadId` of the executor when it is created, and then
comparing against that when `Handle::spawn` is called. If the call is
made from the same thread, `spawn_local` is used directly.
Fixes#562.
This patch keeps the primary net types in `tokio::net` and moves
secondary types to a protocol specific submodules.
Primary types are the ones that users are most likely to name (`TcpStream`,
`TcpListener`, `UdpSocket`, ...)
Secondary types are the operation futures.