Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is SetEvent atomic?

Is it safe to have 2 or more threads call the Win32 API's SetEvent on the same event handler not being protected by a critical section?

like image 697
mikhailitsky Avatar asked May 17 '26 05:05

mikhailitsky


1 Answers

It's safe, but remember that if one thread Sets it, and another thread Sets it at the same time, you're not going to get two notifications, just one; since the 2nd one changed it from True to...True. If you're worried about this, use Semaphores instead.

like image 166
Ana Betts Avatar answered May 20 '26 03:05

Ana Betts