Concurrent.h File Reference

#include <activemq/concurrent/Lock.h>

Namespaces

namespace  activemq
namespace  activemq::concurrent

Defines

#define WAIT_INFINITE   0xFFFFFFFF
#define synchronized(W)

Define Documentation

#define synchronized  ) 
 

Value:

if(false){}                                                   \
        else                                                          \
        for(activemq::concurrent::Lock lock_W(W);                     \
            lock_W.isLocked(); lock_W.unlock())

#define WAIT_INFINITE   0xFFFFFFFF
 

The synchronized macro defines a mechanism for snycronizing a scetion of code. The macro must be passed an object that implements the Syncronizable interface.

The macro works by creating a for loop that will loop exactly once, creating a Lock object that is scoped to the loop. Once the loop conpletes and exits the Lock object goes out of scope releasing the lock on object W. For added safety the if else is used because not all compiles restrict the lifetime of loop variables to the loop, they will however restrict them to the scope of the else.

The macro would be used as follows.

<Syncronizable> X;

somefunction() { syncronized(X) { // Do something that needs syncronizing. } }


Generated on Thu Aug 3 18:03:31 2006 for activemq-cpp by  doxygen 1.4.5