Improve documentation on duplex.rs

Adding example and short documentation for methods.
This example is definitely helpful, but I think it still needs to be accompanied with words explaining the semantics of this function. The nonstandard functions below should also receive the same treatment.

Additionally, relying on `sleep` for correctness is likely to go wrong quickly. You can probably do this in a single-threaded situation without extra tasks.