00001 /* 00002 * Licensed to the Apache Software Foundation (ASF) under one or more 00003 * contributor license agreements. See the NOTICE file distributed with 00004 * this work for additional information regarding copyright ownership. 00005 * The ASF licenses this file to You under the Apache License, Version 2.0 00006 * (the "License"); you may not use this file except in compliance with 00007 * the License. You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 */ 00017 00018 00019 #ifndef _DECAF_INTERNAL_UTIL_CONCURRENT_UNIX_THREADTYPES_H_ 00020 #define _DECAF_INTERNAL_UTIL_CONCURRENT_UNIX_THREADTYPES_H_ 00021 00022 #include <decaf/util/Config.h> 00023 00024 #ifdef HAVE_PTHREAD_H 00025 #include <decaf/internal/util/concurrent/unix/PlatformDefs.h> 00026 #else 00027 #include <decaf/internal/util/concurrent/windows/PlatformDefs.h> 00028 #endif 00029 00030 namespace decaf{ 00031 namespace lang{ 00032 class Thread; 00033 } 00034 namespace internal{ 00035 namespace util{ 00036 namespace concurrent{ 00037 00041 #define DECAF_MAX_TLS_SLOTS 384 00042 00051 typedef PLATFORM_THREAD_CALLBACK_TYPE (PLATFORM_CALLING_CONV *threadMainMethod)(PLATFORM_THREAD_ENTRY_ARG); 00052 00057 typedef void (*threadingTask)(void *); 00058 00059 // Forward Declare some of the nested types. 00060 struct MonitorHandle; 00061 00062 struct ThreadHandle { 00063 decaf::lang::Thread* parent; 00064 decaf_thread_t handle; 00065 decaf_mutex_t mutex; 00066 decaf_condition_t condition; 00067 volatile int state; 00068 volatile int references; 00069 int priority; 00070 bool interrupted; 00071 bool interruptible; 00072 bool timerSet; 00073 bool canceled; 00074 bool unparked; 00075 bool parked; 00076 bool sleeping; 00077 bool waiting; 00078 bool notified; 00079 bool blocked; 00080 bool suspended; 00081 char* name; 00082 long long stackSize; 00083 void *tls[DECAF_MAX_TLS_SLOTS]; 00084 threadingTask threadMain; 00085 void* threadArg; 00086 long long threadId; 00087 bool osThread; 00088 ThreadHandle* interruptingThread; 00089 int numAttached; 00090 ThreadHandle* next; 00091 ThreadHandle* joiners; 00092 MonitorHandle* monitor; 00093 }; 00094 00095 struct MonitorHandle { 00096 char* name; 00097 decaf_mutex_t mutex; 00098 decaf_mutex_t lock; 00099 unsigned int count; 00100 ThreadHandle* owner; 00101 ThreadHandle* waiting; 00102 ThreadHandle* blocking; 00103 bool initialized; 00104 MonitorHandle* next; 00105 }; 00106 00107 class CompletionCondition { 00108 public: 00109 00110 virtual ~CompletionCondition() {} 00111 00122 virtual bool operator()(bool timedOut DECAF_UNUSED) { 00123 return this->operator()(); 00124 } 00125 00130 virtual bool operator()() { 00131 return false; 00132 } 00133 00134 }; 00135 00136 }}}} 00137 00138 #endif /* _DECAF_INTERNAL_UTIL_CONCURRENT_UNIX_THREADTYPES_H_ */
1.6.1