Signals on Windows
I am writing code in C++ using Win32 API wherever needed. I wish to accomplish the following. When a certain event occurs I want to set an alarm() or start a timer which will send a SIGALRM signal to the process after 1s. The process should continu开发者_JAVA百科e once the alarm has been set. It might so happen that I may have to cancel the alarm (or stop the timer) if certain conditions are met. What system calls can help me do this?
Pseudocode:
// to create a waitable, signallable object
HANDLE myHandle = CreateEvent
// to wait for 1000ms
WaitForSingleObject(1000L)
// to interrupt the wait - check return code on WaitForSingleObject for timeout vs signal
SetEvent(myHandle)
Docs for CreateEvent should get you going.
timeSetEvent and timeKillEvent allow the same functionality on windows
加载中,请稍侯......
精彩评论