Skip to content

Commit fff5600

Browse files
committed
Make Unix and Windows impls consistent
There are some explicit Send/Sync implementations for Window's types that don't exist in Unix. While the end result will be the same, I believe it's clearer if we keep the explicit implementations consistent by making the os-specific types Send/Sync where needed and possible. This commit addresses pipe src/libstd/sys/unix/pipe.rs unsafe impl Send for UnixListener {} unsafe impl Sync for UnixListener {} src/libstd/sys/windows/pipe.rs unsafe impl Send for UnixStream {} unsafe impl Sync for UnixStream {} unsafe impl Send for UnixListener {} unsafe impl Sync for UnixListener {} unsafe impl Send for UnixAcceptor {} unsafe impl Sync for UnixAcceptor {} unsafe impl Send for AcceptorState {} unsafe impl Sync for AcceptorState {}
1 parent c80e556 commit fff5600

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

src/libstd/sys/windows/pipe.rs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,9 @@ impl Drop for Event {
129129
}
130130
}
131131

132+
unsafe impl Send for Event {}
133+
unsafe impl Sync for Event {}
134+
132135
struct Inner {
133136
handle: libc::HANDLE,
134137
lock: Mutex<()>,
@@ -156,6 +159,9 @@ impl Drop for Inner {
156159
}
157160
}
158161

162+
unsafe impl Send for Inner {}
163+
unsafe impl Sync for Inner {}
164+
159165
unsafe fn pipe(name: *const u16, init: bool) -> libc::HANDLE {
160166
libc::CreateNamedPipeW(
161167
name,
@@ -220,9 +226,6 @@ pub struct UnixStream {
220226
write_deadline: u64,
221227
}
222228

223-
unsafe impl Send for UnixStream {}
224-
unsafe impl Sync for UnixStream {}
225-
226229
impl UnixStream {
227230
fn try_connect(p: *const u16) -> Option<libc::HANDLE> {
228231
// Note that most of this is lifted from the libuv implementation.
@@ -615,17 +618,11 @@ pub struct UnixAcceptor {
615618
deadline: u64,
616619
}
617620

618-
unsafe impl Send for UnixAcceptor {}
619-
unsafe impl Sync for UnixAcceptor {}
620-
621621
struct AcceptorState {
622622
abort: Event,
623623
closed: AtomicBool,
624624
}
625625

626-
unsafe impl Send for AcceptorState {}
627-
unsafe impl Sync for AcceptorState {}
628-
629626
impl UnixAcceptor {
630627
pub fn accept(&mut self) -> IoResult<UnixStream> {
631628
// This function has some funky implementation details when working with

0 commit comments

Comments
 (0)