about summary refs log tree commit diff
path: root/src/libstd/sys/windows
diff options
context:
space:
mode:
authorAaron Turon <aturon@mozilla.com>2014-10-15 15:45:59 -0700
committerAaron Turon <aturon@mozilla.com>2014-11-08 20:40:38 -0800
commit3d195482a45bf3ed0f12dc9d70d14192262ca711 (patch)
treed9cf1a93cc1e862e641cd17fdb41ebe93d22bfea /src/libstd/sys/windows
parentd34b1b0ca9bf5e0d7cd30952f5de0ab09ed57b41 (diff)
downloadrust-3d195482a45bf3ed0f12dc9d70d14192262ca711.tar.gz
rust-3d195482a45bf3ed0f12dc9d70d14192262ca711.zip
Runtime removal: refactor helper threads
This patch continues the runtime removal by moving
libnative::io::helper_thread into sys::helper_signal and
sys_common::helper_thread

Because this eliminates APIs in `libnative` and `librustrt`, it is a:

[breaking-change]

This functionality is likely to be available publicly, in some form,
from `std` in the future.
Diffstat (limited to 'src/libstd/sys/windows')
-rw-r--r--src/libstd/sys/windows/helper_signal.rs38
-rw-r--r--src/libstd/sys/windows/mod.rs1
2 files changed, 39 insertions, 0 deletions
diff --git a/src/libstd/sys/windows/helper_signal.rs b/src/libstd/sys/windows/helper_signal.rs
new file mode 100644
index 00000000000..c547c79e83a
--- /dev/null
+++ b/src/libstd/sys/windows/helper_signal.rs
@@ -0,0 +1,38 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+use libc::{mod, BOOL, LPCSTR, HANDLE, LPSECURITY_ATTRIBUTES, CloseHandle};
+use ptr;
+
+pub type signal = HANDLE;
+
+pub fn new() -> (HANDLE, HANDLE) {
+    unsafe {
+        let handle = CreateEventA(ptr::null_mut(), libc::FALSE, libc::FALSE,
+                                  ptr::null());
+        (handle, handle)
+    }
+}
+
+pub fn signal(handle: HANDLE) {
+    assert!(unsafe { SetEvent(handle) != 0 });
+}
+
+pub fn close(handle: HANDLE) {
+    assert!(unsafe { CloseHandle(handle) != 0 });
+}
+
+extern "system" {
+    fn CreateEventA(lpSecurityAttributes: LPSECURITY_ATTRIBUTES,
+                    bManualReset: BOOL,
+                    bInitialState: BOOL,
+                    lpName: LPCSTR) -> HANDLE;
+    fn SetEvent(hEvent: HANDLE) -> BOOL;
+}
diff --git a/src/libstd/sys/windows/mod.rs b/src/libstd/sys/windows/mod.rs
index 85fbc6b936c..6f6ca3f2e62 100644
--- a/src/libstd/sys/windows/mod.rs
+++ b/src/libstd/sys/windows/mod.rs
@@ -39,6 +39,7 @@ pub mod os;
 pub mod tcp;
 pub mod udp;
 pub mod pipe;
+pub mod helper_signal;
 
 pub mod addrinfo {
     pub use sys_common::net::get_host_addresses;