All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
PThreadService.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include <pthread.h>
6 #include "IThreadService.h"
7 #include "SpinLock.h"
8 #include <unordered_map>
9 
10 namespace Eegeo
11 {
12  namespace Concurrency
13  {
15  {
16  public:
17 
18  IThreadService::ThreadID CreateThread(ThreadFunc func, void* userData);
19  void JoinThread(IThreadService::ThreadID threadID);
20 
21  private:
22 
23  IThreadService::ThreadID GenerateThreadID();
24 
25  std::unordered_map<IThreadService::ThreadID, pthread_t> m_threads;
26  IThreadService::ThreadID m_nextThreadID;
27  SpinLock m_lock;
28  };
29  }
30 }
31