forked from OSchip/llvm-project
Add an erase() method to llvm::ThreadLocal.
llvm-svn: 109686
This commit is contained in:
parent
b22f1c8bf7
commit
cfc2a57fcd
|
@ -28,6 +28,7 @@ namespace llvm {
|
|||
virtual ~ThreadLocalImpl();
|
||||
void setInstance(const void* d);
|
||||
const void* getInstance();
|
||||
void removeInstance();
|
||||
};
|
||||
|
||||
/// ThreadLocal - A class used to abstract thread-local storage. It holds,
|
||||
|
@ -43,6 +44,9 @@ namespace llvm {
|
|||
|
||||
// set - Associates a pointer to an object with the current thread.
|
||||
void set(T* d) { setInstance(d); }
|
||||
|
||||
// erase - Removes the pointer associated with the current thread.
|
||||
void erase() { removeInstance(); }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,6 +67,10 @@ const void* ThreadLocalImpl::getInstance() {
|
|||
return pthread_getspecific(*key);
|
||||
}
|
||||
|
||||
void ThreadLocalImpl::removeInstance() {
|
||||
setInstance(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#elif defined(LLVM_ON_UNIX)
|
||||
|
|
|
@ -22,4 +22,5 @@ ThreadLocalImpl::ThreadLocalImpl() { }
|
|||
ThreadLocalImpl::~ThreadLocalImpl() { }
|
||||
void ThreadLocalImpl::setInstance(const void* d) { data = const_cast<void*>(d);}
|
||||
const void* ThreadLocalImpl::getInstance() { return data; }
|
||||
void ThreadLocalImpl::removeInstance() { setInstance(0); }
|
||||
}
|
||||
|
|
|
@ -46,4 +46,8 @@ void ThreadLocalImpl::setInstance(const void* d){
|
|||
assert(errorcode != 0);
|
||||
}
|
||||
|
||||
void ThreadLocalImpl::removeInstance() {
|
||||
setInstance(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue