activemq-cpp-3.8.2
ThreadingTypes.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 
19 #ifndef _DECAF_INTERNAL_UTIL_CONCURRENT_UNIX_THREADTYPES_H_
20 #define _DECAF_INTERNAL_UTIL_CONCURRENT_UNIX_THREADTYPES_H_
21 
22 #include <decaf/util/Config.h>
23 
24 #ifdef HAVE_PTHREAD_H
26 #else
28 #endif
29 
30 namespace decaf{
31 namespace lang{
32  class Thread;
33 }
34 namespace internal{
35 namespace util{
36 namespace concurrent{
37 
41  #define DECAF_MAX_TLS_SLOTS 384
42 
52 
57  typedef void (*threadingTask)(void *);
58 
59  // Forward Declare some of the nested types.
60  struct MonitorHandle;
61 
62  struct ThreadHandle {
67  volatile int state;
68  volatile int references;
69  int priority;
72  bool timerSet;
73  bool canceled;
74  bool unparked;
75  bool parked;
76  bool sleeping;
77  bool waiting;
78  bool notified;
79  bool blocked;
80  bool suspended;
81  char* name;
82  long long stackSize;
83  void *tls[DECAF_MAX_TLS_SLOTS];
85  void* threadArg;
86  long long threadId;
87  bool osThread;
93  };
94 
95  struct MonitorHandle {
96  char* name;
99  unsigned int count;
105  };
106 
108  public:
109 
110  virtual ~CompletionCondition() {}
111 
122  virtual bool operator()(bool timedOut DECAF_UNUSED) {
123  return this->operator()();
124  }
125 
130  virtual bool operator()() {
131  return false;
132  }
133 
134  };
135 
136 }}}}
137 
138 #endif /* _DECAF_INTERNAL_UTIL_CONCURRENT_UNIX_THREADTYPES_H_ */
MonitorHandle * next
Definition: ThreadingTypes.h:104
void(* threadingTask)(void *)
The ThreadHandle contains one of these and it should be the method that does the actual work for the ...
Definition: ThreadingTypes.h:57
virtual ~CompletionCondition()
Definition: ThreadingTypes.h:110
bool notified
Definition: ThreadingTypes.h:78
bool parked
Definition: ThreadingTypes.h:75
bool unparked
Definition: ThreadingTypes.h:74
volatile int state
Definition: ThreadingTypes.h:67
long long threadId
Definition: ThreadingTypes.h:86
int priority
Definition: ThreadingTypes.h:69
bool canceled
Definition: ThreadingTypes.h:73
virtual bool operator()(bool timedOut DECAF_UNUSED)
Called from timed wait condition methods to indicate if the timeout has occurred, allows this method ...
Definition: ThreadingTypes.h:122
bool suspended
Definition: ThreadingTypes.h:80
bool timerSet
Definition: ThreadingTypes.h:72
#define DECAF_MAX_TLS_SLOTS
Max number of TLS keys that a thread can use.
Definition: ThreadingTypes.h:41
virtual bool operator()()
Called from non-timed wait conditions to determine if the condition necessary to complete the wait ha...
Definition: ThreadingTypes.h:130
ThreadHandle * blocking
Definition: ThreadingTypes.h:102
void * PLATFORM_THREAD_ENTRY_ARG
Definition: PlatformDefs.h:50
decaf::lang::Thread * parent
Definition: ThreadingTypes.h:63
bool initialized
Definition: ThreadingTypes.h:103
#define PLATFORM_THREAD_CALLBACK_TYPE
Definition: PlatformDefs.h:52
ThreadHandle * interruptingThread
Definition: ThreadingTypes.h:88
volatile int references
Definition: ThreadingTypes.h:68
MonitorHandle * monitor
Definition: ThreadingTypes.h:92
int numAttached
Definition: ThreadingTypes.h:89
decaf_mutex_t mutex
Definition: ThreadingTypes.h:97
long long stackSize
Definition: ThreadingTypes.h:82
void * threadArg
Definition: ThreadingTypes.h:85
pthread_mutex_t * decaf_mutex_t
Definition: PlatformDefs.h:59
pthread_t decaf_thread_t
Definition: PlatformDefs.h:56
decaf_mutex_t lock
Definition: ThreadingTypes.h:98
char * name
Definition: ThreadingTypes.h:81
bool waiting
Definition: ThreadingTypes.h:77
bool blocked
Definition: ThreadingTypes.h:79
ThreadHandle * joiners
Definition: ThreadingTypes.h:91
bool sleeping
Definition: ThreadingTypes.h:76
pthread_cond_t * decaf_condition_t
Definition: PlatformDefs.h:58
bool interrupted
Definition: ThreadingTypes.h:70
A Thread is a concurrent unit of execution.
Definition: Thread.h:64
#define PLATFORM_CALLING_CONV
Definition: PlatformDefs.h:54
bool interruptible
Definition: ThreadingTypes.h:71
decaf_mutex_t mutex
Definition: ThreadingTypes.h:65
unsigned int count
Definition: ThreadingTypes.h:99
ThreadHandle * owner
Definition: ThreadingTypes.h:100
#define DECAF_UNUSED
Definition: Config.h:160
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, the PlatformThread methods will handle calling this method and providing it with its assigned arg.
Definition: ThreadingTypes.h:51
ThreadHandle * next
Definition: ThreadingTypes.h:90
decaf_thread_t handle
Definition: ThreadingTypes.h:64
ThreadHandle * waiting
Definition: ThreadingTypes.h:101
bool osThread
Definition: ThreadingTypes.h:87
char * name
Definition: ThreadingTypes.h:96
decaf_condition_t condition
Definition: ThreadingTypes.h:66
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements...
Definition: AprPool.h:25
threadingTask threadMain
Definition: ThreadingTypes.h:84