Changes between Version 3 and Version 4 of Documentation/SystemQueue


Ignore:
Timestamp:
Dec 17, 2008, 11:43:42 AM (16 years ago)
Author:
Christoph Mayer
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Documentation/SystemQueue

    v3 v4  
    1818== !SystemQueue Internals ==
    1919
     20The !SystemQueue class has one main thread that uses {{{boost::condition}}} with the {{{wait}}} and {{{signal}}} functionality to implement a queue. The thread blocks and waits until a new event is inserted into the queue. It then executes this event and calls the event handler that is assigned to this event. The insertion and execution of an event therefore are decoupled in terms of threading and run asynchronous.
     21
     22One example of events are imcoming network messages. When a packet comes in from the network a new event is generated and the packet attacked to this event. The event is inserted into the !SystemQueue and gets processed asynchronous from the !SystemQueue thread.
     23
    2024== Using the !SystemQueue ==
    2125
     26Every 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
     28Synchronizing 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"
     35using spovnet::common::SystemQueue;
     36using spovnet::common::SystemEvent;
     37using spovnet::common::SystemEventType;
     38using spovnet::common::SystemEventListener;
     39}}}
     40
     41 2. Derive your class from from a {{{SystemEventListener}}} to be able to receive events:
     42
     43{{{
     44#!cpp
     45class MyClass : public SystemEventListener
     46}}}
     47
     48 3. Redefine the {{{SystemEventListener}}} interface:
     49
     50{{{
     51#!cpp
     52protected:
     53    virtual void handleSystemEvent( const SystemEvent& event );
     54}}}
     55
     56
    2257== Using Blocking Code ==
     58
     59