I once saw a snip of code as below,
/** Starts a synchronized block
*
* This macro starts a block synchronized on its argument x
* Note that the synchronized block defines a scope (i.e. { })
* All variables declared in it will live inside this block only
*/
#define SYNCHRONIZE_ON(x) { \
const abcd::LockBase & __lock = \
abcd::MakeLock(x); __lock;
/** Ends a synchronized block */
#define END_SYNCHRONIZE }
The SYNCHRONIZE_ON
and END_SYNCHRONIZE
are used together to synchronize on an object.
The macro SYNCHRONIZE_ON
defines a variable ____lock
in it's block.
The question here is: what is the sentence __lock;
(after the abcd::MakeLock(x);
) for? Notice that this sentence consist of only the variable name.