|
-
November 2nd, 2005, 06:45 AM
#1
Overhead for Sleep(), WaitFor...(), SetEvent()..
Which would be more efficient and accurate to just wait 'x' milliseconds
Sleep(x) or WaitFor SingleObject(hevent, x) where 'hevent' is never signalled?
Also, I have a thread which calls SetEvent() or ResetEvent() depending upon a threshold value of a variable; this variable is updated in a continuously running loop. Since I have no idea how much overhead it takes to call either of these functions, I keep a thread global variable which tracks whether the event is either signalled or unsignalled and call SetEvent() only if the threshold requires a change. There might be an API method of determining if the event is in the signalled or unsignalled state, but I don't know what it is.
Is it worth the effort to minimize the calls to these SetEvent() functions or are they so efficient I am wasting time by making the extra comparisions and the setting of the thread global?
THanks,
Brian
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|