"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "system/Thread.cpp" between
muscle8.20.zip and muscle8.30.zip

About: MUSCLE (Multi User Server Client Linking Environment) is a messaging server and networking API. The included server program ("muscled") lets its clients message each other, and/or store information in its serverside hierarchical database.

Thread.cpp  (muscle8.20):Thread.cpp  (muscle8.30)
skipping to change at line 98 skipping to change at line 98
} }
return B_BAD_OBJECT; return B_BAD_OBJECT;
} }
status_t Thread :: StartInternalThreadAux() status_t Thread :: StartInternalThreadAux()
{ {
if ((_messageSocketsAllocated)||(GetInternalThreadWakeupSocket()())) if ((_messageSocketsAllocated)||(GetInternalThreadWakeupSocket()()))
{ {
_threadRunning = true; // set this first, to avoid a race condition with the thread's startup... _threadRunning = true; // set this first, to avoid a race condition with the thread's startup...
const status_t ret = StartInternalThreadAuxAux();
if (ret.IsOK()) return ret; // success!
_threadRunning = false; // oops, nevermind, thread spawn failed
return ret;
}
else return B_BAD_OBJECT;
}
status_t Thread :: StartInternalThreadAuxAux()
{
#if defined(MUSCLE_USE_CPLUSPLUS11_THREADS) #if defined(MUSCLE_USE_CPLUSPLUS11_THREADS)
# if !defined(MUSCLE_NO_EXCEPTIONS) # if !defined(MUSCLE_NO_EXCEPTIONS)
try { try {
# endif # endif
_thread = std::thread(InternalThreadEntryFunc, this); _thread = std::thread(InternalThreadEntryFunc, this);
return B_NO_ERROR; return B_NO_ERROR;
# if !defined(MUSCLE_NO_EXCEPTIONS) # if !defined(MUSCLE_NO_EXCEPTIONS)
} }
catch(...) {/* empty */} catch(...) {/* empty */}
return B_OUT_OF_MEMORY;
# endif # endif
#elif defined(MUSCLE_USE_PTHREADS) #elif defined(MUSCLE_USE_PTHREADS)
pthread_attr_t attr; pthread_attr_t attr;
if (_suggestedStackSize != 0) if (_suggestedStackSize != 0)
{ {
pthread_attr_init(&attr); pthread_attr_init(&attr);
(void) pthread_attr_setstacksize(&attr, _suggestedStackSize); (void) pthread_attr_setstacksize(&attr, _suggestedStackSize);
} }
return B_ERRNUM(pthread_create(&_thread, (_suggestedStackSize!=0)?&attr:NU return B_ERRNUM(pthread_create(&_thread, (_suggestedStackSize!=0)?&attr:NULL,
LL, InternalThreadEntryFunc, this)); InternalThreadEntryFunc, this));
#elif defined(MUSCLE_PREFER_WIN32_OVER_QT) #elif defined(MUSCLE_PREFER_WIN32_OVER_QT)
typedef unsigned (__stdcall *PTHREAD_START) (void *); typedef unsigned (__stdcall *PTHREAD_START) (void *);
return ((_thread = (::HANDLE)_beginthreadex(NULL, _suggestedStackSize, (PT return ((_thread = (::HANDLE)_beginthreadex(NULL, _suggestedStackSize, (PTHRE
HREAD_START)InternalThreadEntryFunc, this, 0, (unsigned *)&_threadID)) != NULL) AD_START)InternalThreadEntryFunc, this, 0, (unsigned *)&_threadID)) != NULL) ? B
? B_NO_ERROR : B_ERRNO; _NO_ERROR : B_ERRNO;
#elif defined(MUSCLE_USE_QT_THREADS) #elif defined(MUSCLE_USE_QT_THREADS)
_thread.start(); _thread.start();
return B_NO_ERROR; return B_NO_ERROR;
#elif defined(__BEOS__) || defined(__HAIKU__) #elif defined(__BEOS__) || defined(__HAIKU__)
if ((_thread = spawn_thread(InternalThreadEntryFunc, "MUSCLE Thread", B_NO if ((_thread = spawn_thread(InternalThreadEntryFunc, "MUSCLE Thread", B_NORMA
RMAL_PRIORITY, this)) >= 0) L_PRIORITY, this)) >= 0)
{
if (resume_thread(_thread) == B_NO_ERROR) return B_NO_ERROR;
else
{ {
if (resume_thread(_thread).IsOK()) return B_NO_ERROR; ret = B_ERRNO;
else kill_thread(_thread);
{ return ret;
ret = B_ERRNO;
kill_thread(_thread);
return ret;
}
} }
}
return B_ERRNO;
#elif defined(__ATHEOS__) #elif defined(__ATHEOS__)
if ((_thread = spawn_thread("MUSCLE Thread", InternalThreadEntryFunc, NORM if (((_thread = spawn_thread("MUSCLE Thread", InternalThreadEntryFunc, NORMAL
AL_PRIORITY, 32767, this)) >= 0) _PRIORITY, 32767, this)) >= 0)&&(resume_thread(_thread) >= 0)) return B_NO_ERROR
{ ;
if (resume_thread(_thread).IsOK()) return B_NO_ERROR; return B_ERRNO;
else
{
ret = B_ERRNO;
return ret;
}
}
#endif #endif
_threadRunning = false; // oops, nevermind, thread spawn failed
}
return B_BAD_OBJECT;
} }
void Thread :: ShutdownInternalThread(bool waitForThread) void Thread :: ShutdownInternalThread(bool waitForThread)
{ {
if (IsInternalThreadRunning()) if (IsInternalThreadRunning())
{ {
(void) SendMessageToInternalThread(MessageRef()); // a NULL message ref t ells him to quit (void) SendMessageToInternalThread(MessageRef()); // a NULL message ref t ells him to quit
if (waitForThread) WaitForInternalThreadToExit(); if (waitForThread) WaitForInternalThreadToExit();
} }
} }
 End of changes. 12 change blocks. 
42 lines changed or deleted 45 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)