Logo Search packages:      
Sourcecode: csound version File versions  Download package

#define csoundSpinLock ( spinlock   ) 

If the spinlock is not locked, lock it and return; if is is locked, wait until it is unlocked, then lock it and return. Uses atomic compare and swap operations that are safe across processors and safe for out of order operations, and which are more efficient than operating system locks. Use spinlocks to protect access to shared data, especially in functions that do little more than read or write such data, for example:

void write(size_t frames, int* signal) { static int lock = 0; csoundSpinLock(&lock); for (size_t frame = 0; i < frames; frame++) { global_buffer[frame] += signal[frame]; } csoundSpinUnlock(&lock); }

Definition at line 1400 of file csound.h.


Generated by  Doxygen 1.6.0   Back to index