Skip to content

Commit

Permalink
Auto merge of #442 - asomers:kevent, r=posborne
Browse files Browse the repository at this point in the history
impl Send for KEvent

carllerche/mio needs KEvent to be Send-able.  It's safe to send because udata is always treated as a uintptr_t.  The only ways to use udata that wouldn't be Send-able would also be unsafe because they would require casting udata to a pointer.  So I think it's safe to add the Send trait to KEvent.
  • Loading branch information
homu committed Oct 24, 2016
2 parents e618485 + f9b178b commit 62a0168
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/sys/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,15 @@ pub fn kqueue() -> Result<RawFd> {
Errno::result(res)
}


/*
* KEvent can't derive Send because on some operating systems, udata is defined
* as a void*. However, KEvent's public API always treats udata as a uintptr_t,
* which is safe to Send.
*/
unsafe impl Send for KEvent {
}

impl KEvent {
pub fn new(ident: uintptr_t, filter: EventFilter, flags: EventFlag,
fflags:FilterFlag, data: intptr_t, udata: uintptr_t) -> KEvent {
Expand Down

0 comments on commit 62a0168

Please sign in to comment.