activemq-cpp-3.9.5
Concurrent.h File Reference

Go to the source code of this file.

Namespaces

namespace  decaf
 Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
 
namespace  decaf::util
 
namespace  decaf::util::concurrent
 

Macros

#define WAIT_INFINITE   0xFFFFFFFF
 The synchronized macro defines a mechanism for synchronizing a section of code.
 
#define synchronized(W)
 

Macro Definition Documentation

◆ synchronized

#define synchronized ( W)
Value:
if(false){} \
else \
lock_W.isLocked(); lock_W.unlock() )
A wrapper class around a given synchronization mechanism that provides automatic release upon destruc...
Definition Lock.h:34
bool isLocked() const
Indicates whether or not the object is locked.
Definition Lock.h:86

◆ WAIT_INFINITE

#define WAIT_INFINITE   0xFFFFFFFF

The synchronized macro defines a mechanism for synchronizing a section of code.

The macro must be passed an object that implements the Synchronizable 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 completes 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.

Synchronizable X;

somefunction() { synchronized(X) { // Do something that needs synchronizing. } }