rust/src/librustuv
Alex Crichton 56080c4767 Implement clone() for TCP/UDP/Unix sockets
This is part of the overall strategy I would like to take when approaching
issue #11165. The only two I/O objects that reasonably want to be "split" are
the network stream objects. Everything else can be "split" by just creating
another version.

The initial idea I had was the literally split the object into a reader and a
writer half, but that would just introduce lots of clutter with extra interfaces
that were a little unnnecssary, or it would return a ~Reader and a ~Writer which
means you couldn't access things like the remote peer name or local socket name.

The solution I found to be nicer was to just clone the stream itself. The clone
is just a clone of the handle, nothing fancy going on at the kernel level.
Conceptually I found this very easy to wrap my head around (everything else
supports clone()), and it solved the "split" problem at the same time.

The cloning support is pretty specific per platform/lib combination:

* native/win32 - uses some specific WSA apis to clone the SOCKET handle
* native/unix - uses dup() to get another file descriptor
* green/all - This is where things get interesting. When we support full clones
              of a handle, this implies that we're allowing simultaneous writes
              and reads to happen. It turns out that libuv doesn't support two
              simultaneous reads or writes of the same object. It does support
              *one* read and *one* write at the same time, however. Some extra
              infrastructure was added to just block concurrent writers/readers
              until the previous read/write operation was completed.

I've added tests to the tcp/unix modules to make sure that this functionality is
supported everywhere.
2014-02-05 11:43:49 -08:00
..
access.rs Implement clone() for TCP/UDP/Unix sockets 2014-02-05 11:43:49 -08:00
addrinfo.rs libstd: Use iotest! for for get_host_addresses. 2014-01-24 16:44:16 -05:00
async.rs Remove do keyword from librustuv 2014-01-29 09:15:41 -05:00
file.rs rustuv: Require all results are used and fix fallout 2014-02-03 09:32:35 -08:00
homing.rs Implement clone() for TCP/UDP/Unix sockets 2014-02-05 11:43:49 -08:00
idle.rs std: Remove try_send_deferred plus all fallout 2014-02-03 12:05:16 -08:00
lib.rs Implement clone() for TCP/UDP/Unix sockets 2014-02-05 11:43:49 -08:00
macros.rs rustuv: Require all results are used and fix fallout 2014-02-03 09:32:35 -08:00
net.rs Implement clone() for TCP/UDP/Unix sockets 2014-02-05 11:43:49 -08:00
pipe.rs Implement clone() for TCP/UDP/Unix sockets 2014-02-05 11:43:49 -08:00
process.rs rustuv: Reimplement without using std::rt::sched 2013-12-24 14:42:00 -08:00
queue.rs std: Remove try_send_deferred plus all fallout 2014-02-03 12:05:16 -08:00
rc.rs Implement clone() for TCP/UDP/Unix sockets 2014-02-05 11:43:49 -08:00
signal.rs rustuv: Require all results are used and fix fallout 2014-02-03 09:32:35 -08:00
stream.rs Removed all instances of XXX in preparation for relaxing of FIXME rule 2014-01-26 14:42:53 -05:00
timer.rs std: Remove try_send_deferred plus all fallout 2014-02-03 12:05:16 -08:00
tty.rs rustuv: Reimplement without using std::rt::sched 2013-12-24 14:42:00 -08:00
uvio.rs rustuv: Require all results are used and fix fallout 2014-02-03 09:32:35 -08:00
uvll.rs Removed all instances of XXX in preparation for relaxing of FIXME rule 2014-01-26 14:42:53 -05:00