LLVM
3.7.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
work
release_test
rc4
llvm.src
include
llvm
Support
ThreadLocal.h
Go to the documentation of this file.
1
//===- llvm/Support/ThreadLocal.h - Thread Local Data ------------*- C++ -*-===//
2
//
3
// The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
// This file declares the llvm::sys::ThreadLocal class.
11
//
12
//===----------------------------------------------------------------------===//
13
14
#ifndef LLVM_SUPPORT_THREADLOCAL_H
15
#define LLVM_SUPPORT_THREADLOCAL_H
16
17
#include "llvm/Support/DataTypes.h"
18
#include "
llvm/Support/Threading.h
"
19
#include <cassert>
20
21
namespace
llvm {
22
namespace
sys {
23
// ThreadLocalImpl - Common base class of all ThreadLocal instantiations.
24
// YOU SHOULD NEVER USE THIS DIRECTLY.
25
class
ThreadLocalImpl
{
26
typedef
uint64_t ThreadLocalDataTy;
27
/// \brief Platform-specific thread local data.
28
///
29
/// This is embedded in the class and we avoid malloc'ing/free'ing it,
30
/// to make this class more safe for use along with CrashRecoveryContext.
31
union
{
32
char
data
[
sizeof
(ThreadLocalDataTy)];
33
ThreadLocalDataTy
align_data
;
34
};
35
public
:
36
ThreadLocalImpl
();
37
virtual
~ThreadLocalImpl
();
38
void
setInstance
(
const
void
* d);
39
void
*
getInstance
();
40
void
removeInstance
();
41
};
42
43
/// ThreadLocal - A class used to abstract thread-local storage. It holds,
44
/// for each thread, a pointer a single object of type T.
45
template
<
class
T>
46
class
ThreadLocal
:
public
ThreadLocalImpl
{
47
public
:
48
ThreadLocal
() :
ThreadLocalImpl
() { }
49
50
/// get - Fetches a pointer to the object associated with the current
51
/// thread. If no object has yet been associated, it returns NULL;
52
T
*
get
() {
return
static_cast<
T
*
>
(
getInstance
()); }
53
54
// set - Associates a pointer to an object with the current thread.
55
void
set
(
T
* d) {
setInstance
(d); }
56
57
// erase - Removes the pointer associated with the current thread.
58
void
erase
() {
removeInstance
(); }
59
};
60
}
61
}
62
63
#endif
llvm::sys::ThreadLocalImpl::getInstance
void * getInstance()
llvm::sys::ThreadLocalImpl::removeInstance
void removeInstance()
llvm::sys::ThreadLocalImpl::data
char data[sizeof(ThreadLocalDataTy)]
Definition:
ThreadLocal.h:32
llvm::sys::ThreadLocal
ThreadLocal - A class used to abstract thread-local storage.
Definition:
ThreadLocal.h:46
llvm::sys::ThreadLocalImpl::~ThreadLocalImpl
virtual ~ThreadLocalImpl()
llvm::sys::ThreadLocalImpl::ThreadLocalImpl
ThreadLocalImpl()
llvm::sys::ThreadLocalImpl
Definition:
ThreadLocal.h:25
T
llvm::sys::ThreadLocal::erase
void erase()
Definition:
ThreadLocal.h:58
llvm::sys::ThreadLocalImpl::setInstance
void setInstance(const void *d)
llvm::sys::ThreadLocal::ThreadLocal
ThreadLocal()
Definition:
ThreadLocal.h:48
llvm::sys::ThreadLocalImpl::align_data
ThreadLocalDataTy align_data
Definition:
ThreadLocal.h:33
llvm::sys::ThreadLocal::set
void set(T *d)
Definition:
ThreadLocal.h:55
Threading.h
Generated on Mon Aug 31 2015 11:11:00 for LLVM by
1.8.6