diff options
Diffstat (limited to 'src/stable/synchrocounter.h')
-rw-r--r-- | src/stable/synchrocounter.h | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/src/stable/synchrocounter.h b/src/stable/synchrocounter.h index ef86445..17de890 100644 --- a/src/stable/synchrocounter.h +++ b/src/stable/synchrocounter.h | |||
@@ -12,38 +12,38 @@ | |||
12 | 12 | ||
13 | namespace Bu | 13 | namespace Bu |
14 | { | 14 | { |
15 | /** | 15 | /** |
16 | * A simple thread-safe counter class. This is handy for assigning unique | 16 | * A simple thread-safe counter class. This is handy for assigning unique |
17 | * IDs to objects that are being created in different threads. | 17 | * IDs to objects that are being created in different threads. |
18 | *@ingroup Threading Containers | 18 | *@ingroup Threading Containers |
19 | */ | 19 | */ |
20 | template <class T> | 20 | template <class T> |
21 | class SynchroCounter | 21 | class SynchroCounter |
22 | { | 22 | { |
23 | public: | 23 | public: |
24 | SynchroCounter() : | 24 | SynchroCounter() : |
25 | tCounter( 0 ) | 25 | tCounter( 0 ) |
26 | { | 26 | { |
27 | } | 27 | } |
28 | 28 | ||
29 | virtual ~SynchroCounter() | 29 | virtual ~SynchroCounter() |
30 | { | 30 | { |
31 | } | 31 | } |
32 | 32 | ||
33 | T next() | 33 | T next() |
34 | { | 34 | { |
35 | mOperate.lock(); | 35 | mOperate.lock(); |
36 | T tRet = tCounter; | 36 | T tRet = tCounter; |
37 | tCounter++; | 37 | tCounter++; |
38 | mOperate.unlock(); | 38 | mOperate.unlock(); |
39 | 39 | ||
40 | return tRet; | 40 | return tRet; |
41 | } | 41 | } |
42 | 42 | ||
43 | private: | 43 | private: |
44 | T tCounter; /**< The counter itself. */ | 44 | T tCounter; /**< The counter itself. */ |
45 | Mutex mOperate; /**< The master mutex, used on all operations. */ | 45 | Mutex mOperate; /**< The master mutex, used on all operations. */ |
46 | }; | 46 | }; |
47 | } | 47 | } |
48 | 48 | ||
49 | #endif | 49 | #endif |