Skip to content

Commit f5d619c

Browse files
committed
Implement Sync/Send for windows TCP types
1 parent bb315f2 commit f5d619c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/libstd/sys/windows/tcp.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ pub use sys_common::net::TcpStream;
2424

2525
pub struct Event(c::WSAEVENT);
2626

27+
unsafe impl Send for Event {}
28+
unsafe impl Sync for Event {}
29+
2730
impl Event {
2831
pub fn new() -> IoResult<Event> {
2932
let event = unsafe { c::WSACreateEvent() };
@@ -49,6 +52,9 @@ impl Drop for Event {
4952

5053
pub struct TcpListener { sock: sock_t }
5154

55+
unsafe impl Send for TcpListener {}
56+
unsafe impl Sync for TcpListener {}
57+
5258
impl TcpListener {
5359
pub fn bind(addr: ip::SocketAddr) -> IoResult<TcpListener> {
5460
sys::init_net();
@@ -109,13 +115,19 @@ pub struct TcpAcceptor {
109115
deadline: u64,
110116
}
111117

118+
unsafe impl Send for TcpAcceptor {}
119+
unsafe impl Sync for TcpAcceptor {}
120+
112121
struct AcceptorInner {
113122
listener: TcpListener,
114123
abort: Event,
115124
accept: Event,
116125
closed: atomic::AtomicBool,
117126
}
118127

128+
unsafe impl Send for AcceptorInner {}
129+
unsafe impl Sync for AcceptorInner {}
130+
119131
impl TcpAcceptor {
120132
pub fn socket(&self) -> sock_t { self.inner.listener.socket() }
121133

0 commit comments

Comments
 (0)