activemq-cpp-3.9.5
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
27namespace decaf {
28namespace internal {
29namespace util {
30namespace concurrent {
31
32 struct ThreadHandle;
33
34 class DECAF_API PlatformThread {
35 private:
36
37 PlatformThread();
38 PlatformThread(const PlatformThread&);
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
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
92 decaf_mutex_t mutex,
93 CompletionCondition& complete);
94
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
131
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_ */
static void interruptibleWaitOnCondition(decaf_condition_t condition, decaf_mutex_t mutex, CompletionCondition &complete)
static void destroyTlsKey(decaf_tls_key key)
static long long getStackSize(decaf_thread_t thread)
static void writerLockMutex(decaf_rwmutex_t mutex)
static void waitOnCondition(decaf_condition_t condition, decaf_mutex_t mutex)
static bool tryReaderLockMutex(decaf_rwmutex_t mutex)
static void initPriorityMapping(int maxPriority, std::vector< int > &mapping)
Given the Threading libraries max thread priority value, create a mapping to OS level thread prioriti...
static bool tryWriterLockMutex(decaf_rwmutex_t mutex)
static void unlockMutex(decaf_mutex_t mutex)
static bool waitOnCondition(decaf_condition_t condition, decaf_mutex_t mutex, long long mills, int nanos)
static void readerLockMutex(decaf_rwmutex_t mutex)
static void destroyRWMutex(decaf_rwmutex_t mutex)
static void notifyAll(decaf_condition_t condition)
static void unlockRWMutex(decaf_rwmutex_t mutex)
static void createRWMutex(decaf_rwmutex_t *mutex)
static void destroyCondition(decaf_condition_t condition)
static void detachThread(decaf_thread_t handle)
static void createTlsKey(decaf_tls_key *key)
static void notify(decaf_condition_t condition)
static void detachOSThread(decaf_thread_t handle)
static bool tryLockMutex(decaf_mutex_t mutex)
static void setPriority(decaf_thread_t thread, int priority)
static void setTlsValue(decaf_tls_key tlsKey, void *value)
static void setStackSize(decaf_thread_t thread, long long stackSize)
static void createMutex(decaf_mutex_t *mutex)
Creates a new Mutex instance at the location given by the mutex pointer argument.
static void createNewThread(decaf_thread_t *handle, threadMainMethod, void *threadArg, int priority, long long stackSize, long long *threadId)
static bool interruptibleWaitOnCondition(decaf_condition_t condition, decaf_mutex_t mutex, long long mills, int nanos, CompletionCondition &complete)
static void destroyMutex(decaf_mutex_t mutex)
static int getPriority(decaf_thread_t thread)
static void yeild()
Pause the current thread allowing another thread to be scheduled for execution, no guarantee that thi...
static void lockMutex(decaf_mutex_t mutex)
static void * getTlsValue(decaf_tls_key tlsKey)
static void joinThread(decaf_thread_t handle)
static void createCondition(decaf_condition_t *condition)
#define DECAF_API
Definition Config.h:29
Definition Atomics.h:26
pthread_cond_t * decaf_condition_t
Definition PlatformDefs.h:58
pthread_mutex_t * decaf_mutex_t
Definition PlatformDefs.h:59
pthread_t decaf_thread_t
Definition PlatformDefs.h:56
PLATFORM_THREAD_CALLBACK_TYPE(PLATFORM_CALLING_CONV * threadMainMethod)(PLATFORM_THREAD_ENTRY_ARG)
This is the main method for thread instances, this value is valid on any platform,...
Definition ThreadingTypes.h:51
pthread_key_t decaf_tls_key
Definition PlatformDefs.h:57
pthread_rwlock_t * decaf_rwmutex_t
Definition PlatformDefs.h:60
Definition ByteArrayAdapter.h:30
Definition AprPool.h:26
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.
Definition AprPool.h:25