diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-11-05 16:25:16 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2013-11-06 20:40:23 -0500 |
commit | 29d1303e234d5d7ee2f312d28592869f020eb2f2 (patch) | |
tree | 1c2686715c2dfc10d1ec36a2e5e24bd59791847c /include | |
parent | 1d996cee76a50a5a6aa74e21eec89e03a05772e7 (diff) |
Use atomic increment and decrement for thread-safe reference count.
Change-Id: I630298b1c37a6d23c1aa17aabc1c9b2dcb48608a
Diffstat (limited to 'include')
-rw-r--r-- | include/formula/token.hxx | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/include/formula/token.hxx b/include/formula/token.hxx index 8fa8708b5133..ea91e2c4ff7e 100644 --- a/include/formula/token.hxx +++ b/include/formula/token.hxx @@ -29,6 +29,7 @@ #include "formula/formuladllapi.h" #include "formula/types.hxx" #include "svl/sharedstring.hxx" +#include "osl/interlck.h" namespace formula { @@ -107,12 +108,18 @@ public: bool IsFunction() const; // pure functions, no operators bool IsExternalRef() const; sal_uInt8 GetParamCount() const; - inline void IncRef() const { nRefCnt++; } - inline void DecRef() const - { - if (!--nRefCnt) - const_cast<FormulaToken*>(this)->Delete(); - } + + inline void IncRef() const + { + osl_atomic_increment(&nRefCnt); + } + + inline void DecRef() const + { + if (!osl_atomic_decrement(&nRefCnt)) + const_cast<FormulaToken*>(this)->Delete(); + } + inline sal_uInt16 GetRef() const { return nRefCnt; } inline OpCode GetOpCode() const { return eOp; } |