From 3d195482a45bf3ed0f12dc9d70d14192262ca711 Mon Sep 17 00:00:00 2001 From: Aaron Turon Date: Wed, 15 Oct 2014 15:45:59 -0700 Subject: 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. --- src/libstd/sys/windows/helper_signal.rs | 38 +++++++++++++++++++++++++++++++++ src/libstd/sys/windows/mod.rs | 1 + 2 files changed, 39 insertions(+) create mode 100644 src/libstd/sys/windows/helper_signal.rs (limited to 'src/libstd/sys/windows') 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 or the MIT license +// , 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; -- cgit 1.4.1-3-g733a5