An event is a thread synchronising facility that any thread can mutual exclusively put or get representing respectively raising an event and consuming an event. At any moment there's either one event instance or none existing for each event object. All threads expecting an event are blocked and upon the occurrence of the event they compete for it and only one of them will be chosen by the system to consume the event and all the others will remain blocked until its turn. Any active thread can raise an event for one of the waiting threads to consume. If no threads are waiting the event will stay there until a thread comes and gets permitted by the system to grab it. So an event is kind of like a free and shared mutex, the main different between an event and a mutex being that a mutex can only be released (compared with raising an event) by the thread that takes it (compared with consuming an event).

Last edited Sep 13, 2013 at 4:01 AM by quanben, version 3


No comments yet.