Introduce thread local storage

Use thread local storage to store a pointer to the thread we
are running on. This will allow to remove thread info from
Position class.

No functional change.

Signed-off-by: Marco Costalba <mcostalba@gmail.com>
This commit is contained in:
Marco Costalba
2012-04-06 12:39:07 +02:00
parent 797c960d20
commit 699f700162
3 changed files with 22 additions and 3 deletions

View File

@@ -119,7 +119,9 @@ public:
bool use_sleeping_threads() const { return useSleepingThreads; }
int min_split_depth() const { return minimumSplitDepth; }
int size() const { return (int)threads.size(); }
Thread* main_thread() { return threads[0]; }
Thread* main_thread() const { return threads[0]; }
Thread* this_thread() const { return (Thread*)tls_get(tlsKey); }
void set_this_thread(Thread* th) const { tls_set(tlsKey, th); }
void wake_up() const;
void sleep() const;
@@ -138,6 +140,7 @@ private:
std::vector<Thread*> threads;
Thread* timer;
ThreadLocalStorageKey tlsKey;
Lock splitLock;
WaitCondition sleepCond;
Depth minimumSplitDepth;