From bd139e52b44f2a066e6908e1cf84a85e16aa502a Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Fri, 29 Apr 2011 08:27:11 +0000 Subject: * ntdll.h (IsEventSignalled): New inline function. * cygthread.cc (cygthread::terminate_thread): Use IsEventSignalled in place of WaitForSingleObject on event with 0 timeout. * fhandler.cc (fhandler_base_overlapped::has_ongoing_io): Ditto. * fhandler_fifo.cc (fhandler_fifo::open_nonserver): Ditto. (fhandler_fifo::wait): Ditto. * fhandler_termios.cc (fhandler_termios::bg_check): Ditto. * select.cc (verify_tty_slave): Ditto. * thread.cc (pthread::testcancel): Ditto. --- winsup/cygwin/ntdll.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'winsup/cygwin/ntdll.h') diff --git a/winsup/cygwin/ntdll.h b/winsup/cygwin/ntdll.h index e9ff11bf0..b420f02d5 100644 --- a/winsup/cygwin/ntdll.h +++ b/winsup/cygwin/ntdll.h @@ -1292,6 +1292,18 @@ extern "C" fbi.FileAttributes = attr ?: FILE_ATTRIBUTE_NORMAL; return NtSetInformationFile(h, &io, &fbi, sizeof fbi, FileBasicInformation); } + + /* This test for a signalled event is twice as fast as calling + WaitForSingleObject (event, 0). */ + inline + BOOL NTAPI IsEventSignalled (HANDLE event) + { + EVENT_BASIC_INFORMATION ebi; + return NT_SUCCESS (NtQueryEvent (event, EventBasicInformation, + &ebi, sizeof ebi, NULL)) + && ebi.SignalState != 0; + + } } #endif #endif /*_NTDLL_H*/ -- cgit v1.2.3