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 {}
This commit is contained in:
parent
c80e556e15
commit
fff5600925
|
@ -129,6 +129,9 @@ impl Drop for Event {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsafe impl Send for Event {}
|
||||||
|
unsafe impl Sync for Event {}
|
||||||
|
|
||||||
struct Inner {
|
struct Inner {
|
||||||
handle: libc::HANDLE,
|
handle: libc::HANDLE,
|
||||||
lock: Mutex<()>,
|
lock: Mutex<()>,
|
||||||
|
@ -156,6 +159,9 @@ impl Drop for Inner {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsafe impl Send for Inner {}
|
||||||
|
unsafe impl Sync for Inner {}
|
||||||
|
|
||||||
unsafe fn pipe(name: *const u16, init: bool) -> libc::HANDLE {
|
unsafe fn pipe(name: *const u16, init: bool) -> libc::HANDLE {
|
||||||
libc::CreateNamedPipeW(
|
libc::CreateNamedPipeW(
|
||||||
name,
|
name,
|
||||||
|
@ -220,9 +226,6 @@ pub struct UnixStream {
|
||||||
write_deadline: u64,
|
write_deadline: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for UnixStream {}
|
|
||||||
unsafe impl Sync for UnixStream {}
|
|
||||||
|
|
||||||
impl UnixStream {
|
impl UnixStream {
|
||||||
fn try_connect(p: *const u16) -> Option<libc::HANDLE> {
|
fn try_connect(p: *const u16) -> Option<libc::HANDLE> {
|
||||||
// Note that most of this is lifted from the libuv implementation.
|
// Note that most of this is lifted from the libuv implementation.
|
||||||
|
@ -615,17 +618,11 @@ pub struct UnixAcceptor {
|
||||||
deadline: u64,
|
deadline: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for UnixAcceptor {}
|
|
||||||
unsafe impl Sync for UnixAcceptor {}
|
|
||||||
|
|
||||||
struct AcceptorState {
|
struct AcceptorState {
|
||||||
abort: Event,
|
abort: Event,
|
||||||
closed: AtomicBool,
|
closed: AtomicBool,
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for AcceptorState {}
|
|
||||||
unsafe impl Sync for AcceptorState {}
|
|
||||||
|
|
||||||
impl UnixAcceptor {
|
impl UnixAcceptor {
|
||||||
pub fn accept(&mut self) -> IoResult<UnixStream> {
|
pub fn accept(&mut self) -> IoResult<UnixStream> {
|
||||||
// This function has some funky implementation details when working with
|
// This function has some funky implementation details when working with
|
||||||
|
|
Loading…
Reference in New Issue