|
|
1.1 ! root 1: #include "Event.h" ! 2: ! 3: namespace TrueCrypt ! 4: { ! 5: void Event::Connect (const EventConnectorBase &connector) ! 6: { ! 7: ScopeLock lock (HandlersMutex); ! 8: ConnectedHandlers.push_back (shared_ptr <EventConnectorBase> (connector.CloneNew())); ! 9: } ! 10: ! 11: void Event::Disconnect (void *handler) ! 12: { ! 13: ScopeLock lock (HandlersMutex); ! 14: ! 15: EventHandlerList newConnectedHandlers; ! 16: foreach (shared_ptr <EventConnectorBase> h, ConnectedHandlers) ! 17: { ! 18: if (h->GetHandler() != handler) ! 19: newConnectedHandlers.push_back (h); ! 20: } ! 21: ! 22: ConnectedHandlers = newConnectedHandlers; ! 23: } ! 24: ! 25: void Event::Raise () ! 26: { ! 27: EventArgs args; ! 28: Raise (args); ! 29: } ! 30: ! 31: void Event::Raise (EventArgs &args) ! 32: { ! 33: ScopeLock lock (HandlersMutex); ! 34: foreach_ref (EventConnectorBase &handler, ConnectedHandlers) ! 35: { ! 36: handler (args); ! 37: } ! 38: } ! 39: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.