1 |
/*************************************************************************** |
/*************************************************************************** |
2 |
* * |
* * |
3 |
* Copyright (C) 2006-2009 Andreas Persson * |
* Copyright (C) 2006-2012 Andreas Persson * |
4 |
* * |
* * |
5 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
6 |
* it under the terms of the GNU General Public License as published by * |
* it under the terms of the GNU General Public License as published by * |
28 |
namespace LinuxSampler { |
namespace LinuxSampler { |
29 |
|
|
30 |
/** |
/** |
31 |
* Thread safe management of configuration data, where the data is |
* Thread-safe management of configuration data, where the data is |
32 |
* updated by a single non real time thread and read by a number |
* updated by a single non real time thread and read by a number |
33 |
* of real time threads. |
* of real time threads. |
34 |
* |
* |
46 |
* the data to be read, and Unlock() must be called when finished |
* the data to be read, and Unlock() must be called when finished |
47 |
* reading the data. (Neither Lock nor Unlock will block the real |
* reading the data. (Neither Lock nor Unlock will block the real |
48 |
* time thread, or use any system calls.) |
* time thread, or use any system calls.) |
49 |
|
* |
50 |
|
* Note that the non real time side isn't safe for concurrent |
51 |
|
* access, so if there are multiple non real time threads that |
52 |
|
* update the configuration data, a mutex has to be used. |
53 |
|
* |
54 |
|
* Implementation note: the memory order parameters and fences are |
55 |
|
* very carefully chosen to make the code fast but still safe for |
56 |
|
* memory access reordering made by the CPU. |
57 |
*/ |
*/ |
58 |
template<class T> |
template<class T> |
59 |
class SynchronizedConfig { |
class SynchronizedConfig { |