diff options
Diffstat (limited to 'cpp/sca/kernel/function.hpp')
-rw-r--r-- | cpp/sca/kernel/function.hpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/cpp/sca/kernel/function.hpp b/cpp/sca/kernel/function.hpp index 9492879e5e..c99ee5dbad 100644 --- a/cpp/sca/kernel/function.hpp +++ b/cpp/sca/kernel/function.hpp @@ -64,8 +64,6 @@ bool printLambdaCounters() { template<typename R, typename... P> class Callable { public: - unsigned int refCount; - Callable() : refCount(0) { } @@ -76,14 +74,6 @@ public: virtual ~Callable() { } - unsigned int acquire() { - return __sync_add_and_fetch(&refCount, 1); - } - - unsigned int release() { - return __sync_sub_and_fetch(&refCount, 1); - } - template<typename F> class Proxy: public Callable { public: Proxy(const F& f) : function(f) { @@ -112,6 +102,18 @@ public: const F function; }; +private: + friend class gc_counting_ptr<Callable>; + + unsigned int refCount; + + unsigned int acquire() { + return __sync_add_and_fetch(&refCount, 1); + } + + unsigned int release() { + return __sync_sub_and_fetch(&refCount, 1); + } }; template<typename S> class lambda; |