29 #if !defined ONLY_LOCAL_PROXY || defined INCLUDE_MIDDLE_MIX
38 const int l4thread_max_threads = 64;
41 #ifdef PRINT_THREAD_STACK_TRACE
42 pthread_once_t CAThread::ms_threadKeyInit = PTHREAD_ONCE_INIT;
43 pthread_key_t CAThread::ms_threadKey;
44 const char* CAThread::METHOD_BEGIN =
"Begin of method";
45 const char* CAThread::METHOD_END =
"End of method";
48 #if defined (DEBUG) && ! defined(ONLY_LOCAL_PROXY)
58 m_Thread=L4THREAD_INVALID_ID;
59 #ifdef PRINT_THREAD_STACK_TRACE
60 assert(ms_threadKey != L4_ENOKEY);
74 m_Thread=L4THREAD_INVALID_ID;
89 #ifdef PRINT_THREAD_STACK_TRACE
90 void CAThread::destroyValue(
void* a_value)
92 delete (METHOD_STACK* )a_value;
95 void CAThread::initKey()
97 pthread_key_create(&ms_threadKey, destroyValue);
100 void CAThread::setCurrentStack(METHOD_STACK* a_value)
102 pthread_once(&ms_threadKeyInit, initKey);
103 METHOD_STACK* value = (METHOD_STACK*)pthread_getspecific(ms_threadKey);
105 pthread_setspecific(ms_threadKey, a_value);
108 METHOD_STACK* CAThread::getCurrentStack()
110 pthread_once(&ms_threadKeyInit, initKey);
111 return (METHOD_STACK*)pthread_getspecific(ms_threadKey);
130 if ((m_Thread = l4thread_create(
m_fncMainLoop, param, L4THREAD_CREATE_ASYNC)) < 1)
132 m_Thread = L4THREAD_INVALID_ID;
134 CAMsg::printMsg(LOG_ERR,
"CAThread::start() - creating new thread failed!\n");
142 CAMsg::printMsg(LOG_ERR,
"CAThread::start() - creating new thread failed! - Err: %i\n",ret);
148 #if defined _DEBUG && !defined(ONLY_LOCAL_PROXY)
149 if(m_pThreadList != NULL)
151 m_pThreadList->put(
this);
156 CAMsg::printMsg(LOG_DEBUG,
"CAThread::start() - Warning no thread list found\n");
161 CAMsg::printMsg(LOG_DEBUG,
"CAThread::start() - thread created sucessful\n");
168 "Thread with name: %s created - pthread_t: "l4util_idfmt
"\n",
169 m_strName, l4util_idstr(l4thread_l4_id(m_Thread)));
191 if(m_Thread==L4THREAD_INVALID_ID)
201 #if defined DEBUG && !defined ONLY_LOCAL_PROXY
203 m_pThreadList->remove(
this);
212 CAMsg::printMsg(LOG_ERR,
"CAThread - join() not successful - Error was: %i\n",ret);
UINT8 * bytes2hex(const void *bytes, UINT32 len)
Converts the byte array to a hex string.
static SINT32 printMsg(UINT32 typ, const char *format,...)
Writes a given message to the log.
THREAD_MAIN_TYP m_fncMainLoop
CAThread()
Creates a CAThread object but no actual thread.
SINT32 start(void *param, bool bDaemon=false, bool bSilent=false)
Starts the execution of the main function of this thread.
SINT32 join()
Waits for the main function to finish execution.