activemq-cpp-3.6.0
PlatformThread.h
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one or more
3  * contributor license agreements. See the NOTICE file distributed with
4  * this work for additional information regarding copyright ownership.
5  * The ASF licenses this file to You under the Apache License, Version 2.0
6  * (the "License"); you may not use this file except in compliance with
7  * the License. You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef _DECAF_INTERNAL_UTIL_CONCURRENT_PLATFORMTHREAD_H_
19 #define _DECAF_INTERNAL_UTIL_CONCURRENT_PLATFORMTHREAD_H_
20 
21 #include <decaf/util/Config.h>
22 
24 
25 #include <vector>
26 
27 namespace decaf {
28 namespace internal {
29 namespace util {
30 namespace concurrent {
31 
32  struct ThreadHandle;
33 
35  private:
36 
39  PlatformThread& operator= (const PlatformThread&);
40 
41  public: // Mutex processing methods
42 
51  static void createMutex(decaf_mutex_t* mutex);
52 
53  static void lockMutex(decaf_mutex_t mutex);
54 
55  static bool tryLockMutex(decaf_mutex_t mutex);
56 
57  static void unlockMutex(decaf_mutex_t mutex);
58 
59  static void destroyMutex(decaf_mutex_t mutex);
60 
61  public: // Reader / Writer Mutex processing methods.
62 
63  static void createRWMutex(decaf_rwmutex_t* mutex);
64 
65  static void readerLockMutex(decaf_rwmutex_t mutex);
66  static void writerLockMutex(decaf_rwmutex_t mutex);
67 
68  static bool tryReaderLockMutex(decaf_rwmutex_t mutex);
69  static bool tryWriterLockMutex(decaf_rwmutex_t mutex);
70 
71  static void unlockRWMutex(decaf_rwmutex_t mutex);
72 
73  static void destroyRWMutex(decaf_rwmutex_t mutex);
74 
75  public: // Condition processing methods
76 
77  static void createCondition(decaf_condition_t* condition);
78 
79  static void notify(decaf_condition_t condition);
80 
81  static void notifyAll(decaf_condition_t condition);
82 
83  static void waitOnCondition(decaf_condition_t condition, decaf_mutex_t mutex);
84 
88  static bool waitOnCondition(decaf_condition_t condition, decaf_mutex_t mutex,
89  long long mills, int nanos);
90 
91  static void interruptibleWaitOnCondition(decaf_condition_t condition,
92  decaf_mutex_t mutex,
93  CompletionCondition& complete);
94 
98  static bool interruptibleWaitOnCondition(decaf_condition_t condition, decaf_mutex_t mutex,
99  long long mills, int nanos, CompletionCondition& complete);
100 
101  static void destroyCondition(decaf_condition_t condition);
102 
103  public: // Thread Methods.
104 
117  static void initPriorityMapping(int maxPriority, std::vector<int>& mapping);
118 
119  static void createNewThread(decaf_thread_t* handle, threadMainMethod, void* threadArg,
120  int priority, long long stackSize, long long* threadId);
121 
122  static void detachThread(decaf_thread_t handle);
123 
124  static void detachOSThread(decaf_thread_t handle);
125 
126  static void joinThread(decaf_thread_t handle);
127 
128  static void exitThread();
129 
130  static decaf_thread_t getCurrentThread();
131 
132  static decaf_thread_t getSafeOSThreadHandle();
133 
134  static long long getCurrentThreadId();
135 
136  static int getPriority(decaf_thread_t thread);
137 
138  static void setPriority(decaf_thread_t thread, int priority);
139 
140  static long long getStackSize(decaf_thread_t thread);
141 
142  static void setStackSize(decaf_thread_t thread, long long stackSize);
143 
148  static void yeild();
149 
150  public: // Thread Local Methods
151 
152  static void createTlsKey(decaf_tls_key* key);
153 
154  static void destroyTlsKey(decaf_tls_key key);
155 
156  static void* getTlsValue(decaf_tls_key tlsKey);
157 
158  static void setTlsValue(decaf_tls_key tlsKey, void* value);
159 
160  };
161 
162 }}}}
163 
164 #endif /* _DECAF_INTERNAL_UTIL_CONCURRENT_PLATFORMTHREAD_H_ */