summaryrefslogtreecommitdiff
path: root/includes/Handle.h
diff options
context:
space:
mode:
authorNicolas Noble <pixel@nobis-crew.org>2013-12-18 18:10:39 -0800
committerNicolas Noble <pixel@nobis-crew.org>2013-12-18 18:10:39 -0800
commitd489bcc2cba7c454874ae09e2e1df5d9dc6958aa (patch)
treedcf09d48f609fd7a7834e311663a3885b17459bf /includes/Handle.h
parent9e2b2679cb94ba4950aa98323e4c61a3e53546e2 (diff)
Removing Atomic.h and all volatiles.
Diffstat (limited to 'includes/Handle.h')
-rw-r--r--includes/Handle.h10
1 files changed, 5 insertions, 5 deletions
diff --git a/includes/Handle.h b/includes/Handle.h
index 1753cb6..15415a6 100644
--- a/includes/Handle.h
+++ b/includes/Handle.h
@@ -1,10 +1,10 @@
#pragma once
+#include <atomic>
#include <Task.h>
#include <Exceptions.h>
#include <Printer.h>
#include <BString.h>
-#include <Atomic.h>
namespace Balau {
@@ -84,13 +84,13 @@ class Handle {
ssize_t forceWrite(const void * buf, size_t count, Events::BaseEvent * evt = NULL) throw (GeneralException) __attribute__((warn_unused_result));
protected:
- Handle() { }
+ Handle() : m_refCount(0) { }
private:
// the IO<> refcounting mechanism
- void addRef() { Atomic::Increment(&m_refCount); }
+ void addRef() { ++m_refCount; }
void delRef() {
- if (Atomic::Decrement(&m_refCount) == 0) {
+ if (--m_refCount == 0) {
if (!isClosed())
close();
delete this;
@@ -100,7 +100,7 @@ class Handle {
template<class T>
friend class IO;
- volatile int m_refCount = 0;
+ std::atomic<int> m_refCount;
Handle(const Handle &) = delete;
Handle & operator=(const Handle &) = delete;