From e5d3e5180f667f8850cdd96af60fc5511746b1bd Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 21 Apr 2014 20:30:07 -0700 Subject: std: Add support for an accept() timeout This adds experimental support for timeouts when accepting sockets through `TcpAcceptor::accept`. This does not add a separate `accept_timeout` function, but rather it adds a `set_timeout` function instead. This second function is intended to be used as a hard deadline after which all accepts will never block and fail immediately. This idea was derived from Go's SetDeadline() methods. We do not currently have a robust time abstraction in the standard library, so I opted to have the argument be a relative time in millseconds into the future. I believe a more appropriate argument type is an absolute time, but this concept does not exist yet (this is also why the function is marked #[experimental]). The native support is built on select(), similarly to connect_timeout(), and the green support is based on channel select and a timer. cc #13523 --- src/libstd/rt/rtio.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'src/libstd/rt') diff --git a/src/libstd/rt/rtio.rs b/src/libstd/rt/rtio.rs index 0f3fc9c21ce..5dd14834669 100644 --- a/src/libstd/rt/rtio.rs +++ b/src/libstd/rt/rtio.rs @@ -200,6 +200,7 @@ pub trait RtioTcpAcceptor : RtioSocket { fn accept(&mut self) -> IoResult<~RtioTcpStream:Send>; fn accept_simultaneously(&mut self) -> IoResult<()>; fn dont_accept_simultaneously(&mut self) -> IoResult<()>; + fn set_timeout(&mut self, timeout: Option); } pub trait RtioTcpStream : RtioSocket { -- cgit 1.4.1-3-g733a5