diff options
author | megamage <none@none> | 2009-08-08 12:37:33 -0500 |
---|---|---|
committer | megamage <none@none> | 2009-08-08 12:37:33 -0500 |
commit | 1165b889a048a5c448305848f668232c9f683969 (patch) | |
tree | f77d7b58f091181b8c0f50359cd1338e6b7eef1d /src/shared/Threading.h | |
parent | a3ee65bee10ab7698c750be4d60dac8daa972aa7 (diff) |
[8328] Fixed problem with crash at startup in result destroy anti-freeze thread runnable. Author: VladimirMangos
* Destroy runnable only if no references.
* Some code cleanups
--HG--
branch : trunk
Diffstat (limited to 'src/shared/Threading.h')
-rw-r--r-- | src/shared/Threading.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/shared/Threading.h b/src/shared/Threading.h index ab423696cd1..6c3f3724bc1 100644 --- a/src/shared/Threading.h +++ b/src/shared/Threading.h @@ -21,6 +21,7 @@ #include <ace/Thread.h> #include <ace/TSS_T.h> +#include "ace/Atomic_Op.h" #include <assert.h> #include "Errors.h" @@ -32,6 +33,15 @@ namespace ACE_Based public: virtual ~Runnable() {} virtual void run() = 0; + + void incReference() { ++m_refs; } + void decReference() + { + if(!--m_refs) + delete this; + } + private: + ACE_Atomic_Op<ACE_Thread_Mutex, int> m_refs; }; enum Priority |