activemq-cpp-3.9.5
|
#include <decaf/util/concurrent/Lock.h>
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) |
#define synchronized | ( | W | ) |
#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. } }