TheSauce
July 28th, 2005, 07:08 PM
Hi, I'm using SetEvent and WaitForSingleObject to stop a worker thread when its run out of work to do and to wake it back up when the main thread has given it more work to do.
The event is created using CreateEvent(NULL, false, false, NULL);
The event handle is a volitile varible in a class that both threads have a pointer to.
The main thread calls SetEvent each time it adds more data for the worker thread. The worker thread tends to go to sleep quite often (15 times a second or so).
My problem is that the call to SetEvent takes 4milliseconds 75%+ of the time. This is on a AMD64 3200+. This is clearly a huge amount of time. It's quick sometimes, but it's usually slow
So the question is what am I doing wrong? I assume this isn't the normal behavior of this function, so does anyone have any suggestions on what could be causing this?
Thanks a lot
Malcolm
The event is created using CreateEvent(NULL, false, false, NULL);
The event handle is a volitile varible in a class that both threads have a pointer to.
The main thread calls SetEvent each time it adds more data for the worker thread. The worker thread tends to go to sleep quite often (15 times a second or so).
My problem is that the call to SetEvent takes 4milliseconds 75%+ of the time. This is on a AMD64 3200+. This is clearly a huge amount of time. It's quick sometimes, but it's usually slow
So the question is what am I doing wrong? I assume this isn't the normal behavior of this function, so does anyone have any suggestions on what could be causing this?
Thanks a lot
Malcolm