| 26 | Every mechanisms that gets triggered by some external event must get synchronized with the main !SystemQueue thread. If you e.g. observe the network card and want to execute some stuff on network changes, you must synchronized with the !SystemQueue. Why? Because a network packet might get processed and call some code that you would maybe call, too. Therefore producing parallel access to some code and causing threading problems. |
| 27 | |
| 28 | Synchronizing with the main Ariba thread is easy, thanks to the !SystemQueue. We will not explain step-by-step how to use the !SystemQueue in your code: |
| 29 | |
| 30 | 1. In you {{{.h}}} file integrate the !SystemQueue header and some {{{using declerations}}}; |
| 31 | |
| 32 | {{{ |
| 33 | #!cpp |
| 34 | #include "spovnet/common/system/SystemQueue.h" |
| 35 | using spovnet::common::SystemQueue; |
| 36 | using spovnet::common::SystemEvent; |
| 37 | using spovnet::common::SystemEventType; |
| 38 | using spovnet::common::SystemEventListener; |
| 39 | }}} |
| 40 | |
| 41 | 2. Derive your class from from a {{{SystemEventListener}}} to be able to receive events: |
| 42 | |
| 43 | {{{ |
| 44 | #!cpp |
| 45 | class MyClass : public SystemEventListener |
| 46 | }}} |
| 47 | |
| 48 | 3. Redefine the {{{SystemEventListener}}} interface: |
| 49 | |
| 50 | {{{ |
| 51 | #!cpp |
| 52 | protected: |
| 53 | virtual void handleSystemEvent( const SystemEvent& event ); |
| 54 | }}} |
| 55 | |
| 56 | |