Honeycomb  0.1
Component-Model Framework
Thread.h
Go to the documentation of this file.
1 // Honeycomb, Copyright (C) 2013 Daniel Carter. Distributed under the Boost Software License v1.0.
2 #pragma once
3 
5 namespace honey
6 {
7 
8 namespace thread
9 {
10  namespace platform
11  {
12  struct LocalStore;
13  }
14 
15  namespace current { namespace platform
16  {
17  inline void yield() { SwitchToThread(); }
18  inline void pause() { YieldProcessor(); }
19  } }
20 }
21 
22 namespace platform
23 {
24 
25 class Thread
26 {
27  typedef thread::platform::LocalStore LocalStore;
28  friend struct LocalStore;
29 public:
30  Thread(bool external, int stackSize);
31  Thread(Thread&& rhs);
32  virtual ~Thread();
33 
34  Thread& operator=(Thread&& rhs);
35 
36  static Thread& current();
37 
38  void start();
39  void join();
40 
41  static const int priorityNormal = 0;
42  static const int priorityMin = -2;
43  static const int priorityMax = 2;
44  void setPriority(int priority);
45  int getPriority() const;
46 
47  typedef int32 ThreadId;
48  static const ThreadId threadIdInvalid = 0;
49  ThreadId threadId() const { return _id; }
50 
51  static int concurrency() { static int ret = concurrency_priv(); return ret; }
52 
53 private:
54  void finalize();
55 
56  static Thread* createExt();
57  static DWORD WINAPI entry(void* arg);
58  static int concurrency_priv();
59 
60  HANDLE _handle;
61  ThreadId _id;
62  int _stackSize;
63 };
64 
65 } }
void yield()
Give up this thread's time slice to allow other threads to execute.
Definition: Thread.h:52
void pause()
Perform a no-op without giving up this thread's time slice. This no-op momentarily frees resources fo...
Definition: Thread.h:54
int int32
Definition: Core.h:15
Global Honeycomb namespace.