"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/common/ThreadStart.cpp" between
Firebird-3.0.2.32703-0.tar.bz2 and Firebird-3.0.4.33054-0.tar.bz2

About: Firebird is a relational database offering many ANSI SQL standard features.

ThreadStart.cpp  (Firebird-3.0.2.32703-0.tar.bz2):ThreadStart.cpp  (Firebird-3.0.4.33054-0.tar.bz2)
skipping to change at line 88 skipping to change at line 88
private: private:
ThreadArgs& operator=(const ThreadArgs&); ThreadArgs& operator=(const ThreadArgs&);
}; };
#ifdef __cplusplus #ifdef __cplusplus
extern "C" extern "C"
#endif #endif
THREAD_ENTRY_DECLARE threadStart(THREAD_ENTRY_PARAM arg) THREAD_ENTRY_DECLARE threadStart(THREAD_ENTRY_PARAM arg)
{ {
fb_assert(arg); fb_assert(arg);
Firebird::ThreadSync thread("threadStart"); Firebird::ThreadSync* thread = FB_NEW Firebird::ThreadSync("threadStart")
;
MemoryPool::setContextPool(getDefaultMemoryPool()); MemoryPool::setContextPool(getDefaultMemoryPool());
ThreadArgs localArgs(*static_cast<ThreadArgs*>(arg)); ThreadArgs localArgs(*static_cast<ThreadArgs*>(arg));
delete static_cast<ThreadArgs*>(arg); delete static_cast<ThreadArgs*>(arg);
localArgs.run(); localArgs.run();
// Check if ThreadSync still exists before deleting
thread = Firebird::ThreadSync::findThread();
delete thread;
return 0; return 0;
} }
} // anonymous namespace } // anonymous namespace
#ifdef USE_POSIX_THREADS #ifdef USE_POSIX_THREADS
#define START_THREAD #define START_THREAD
void Thread::start(ThreadEntryPoint* routine, void* arg, int priority_arg, Handl e* p_handle) ThreadId Thread::start(ThreadEntryPoint* routine, void* arg, int priority_arg, H andle* p_handle)
{ {
/************************************** /**************************************
* *
* t h r e a d _ s t a r t ( P O S I X ) * t h r e a d _ s t a r t ( P O S I X )
* *
************************************** **************************************
* *
* Functional description * Functional description
* Start a new thread. Return 0 if successful, * Start a new thread. Return 0 if successful,
* status if not. * status if not.
skipping to change at line 182 skipping to change at line 188
if (p_handle) if (p_handle)
{ {
#ifdef HAVE_PTHREAD_CANCEL #ifdef HAVE_PTHREAD_CANCEL
int dummy; // We do not want to know old cancel type int dummy; // We do not want to know old cancel type
state = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &dummy ); state = pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &dummy );
if (state) if (state)
Firebird::system_call_failed::raise("pthread_setcancelty pe", state); Firebird::system_call_failed::raise("pthread_setcancelty pe", state);
#endif #endif
*p_handle = thread; *p_handle = thread;
} }
return getId();
} }
void Thread::waitForCompletion(Handle& thread) void Thread::waitForCompletion(Handle& thread)
{ {
int state = pthread_join(thread, NULL); int state = pthread_join(thread, NULL);
if (state) if (state)
Firebird::system_call_failed::raise("pthread_join", state); Firebird::system_call_failed::raise("pthread_join", state);
} }
void Thread::kill(Handle& thread) void Thread::kill(Handle& thread)
skipping to change at line 210 skipping to change at line 217
ThreadId Thread::getId() ThreadId Thread::getId()
{ {
#if defined(LINUX) && !defined(ANDROID) #if defined(LINUX) && !defined(ANDROID)
return syscall(SYS_gettid); return syscall(SYS_gettid);
#else #else
return pthread_self(); return pthread_self();
#endif #endif
} }
bool Thread::isCurrent(const ThreadId threadId)
{
return getId() == threadId;
}
void Thread::sleep(unsigned milliseconds) void Thread::sleep(unsigned milliseconds)
{ {
#if defined(HAVE_NANOSLEEP) #if defined(HAVE_NANOSLEEP)
timespec timer, rem; timespec timer, rem;
timer.tv_sec = milliseconds / 1000; timer.tv_sec = milliseconds / 1000;
timer.tv_nsec = (milliseconds % 1000) * 1000000; timer.tv_nsec = (milliseconds % 1000) * 1000000;
while (nanosleep(&timer, &rem) != 0) while (nanosleep(&timer, &rem) != 0)
{ {
if (errno != EINTR) if (errno != EINTR)
skipping to change at line 253 skipping to change at line 265
sched_yield(); sched_yield();
#else #else
pthread_yield(); pthread_yield();
#endif // _POSIX_PRIORITY_SCHEDULING #endif // _POSIX_PRIORITY_SCHEDULING
} }
#endif // USE_POSIX_THREADS #endif // USE_POSIX_THREADS
#ifdef WIN_NT #ifdef WIN_NT
#define START_THREAD #define START_THREAD
void Thread::start(ThreadEntryPoint* routine, void* arg, int priority_arg, Handl e* p_handle) ThreadId Thread::start(ThreadEntryPoint* routine, void* arg, int priority_arg, H andle* p_handle)
{ {
/************************************** /**************************************
* *
* t h r e a d _ s t a r t ( W I N _ N T ) * t h r e a d _ s t a r t ( W I N _ N T )
* *
************************************** **************************************
* *
* Functional description * Functional description
* Start a new thread. Return 0 if successful, * Start a new thread. Return 0 if successful,
* status if not. * status if not.
skipping to change at line 317 skipping to change at line 329
ResumeThread(handle); ResumeThread(handle);
if (p_handle) if (p_handle)
{ {
*p_handle = handle; *p_handle = handle;
} }
else else
{ {
CloseHandle(handle); CloseHandle(handle);
} }
return thread_id;
} }
void Thread::waitForCompletion(Handle& handle) void Thread::waitForCompletion(Handle& handle)
{ {
// When current DLL is unloading, OS loader holds loader lock. When threa d is // When current DLL is unloading, OS loader holds loader lock. When threa d is
// exiting, OS notifies every DLL about it, and acquires loader lock. In such // exiting, OS notifies every DLL about it, and acquires loader lock. In such
// scenario waiting on thread handle will never succeed. // scenario waiting on thread handle will never succeed.
if (!Firebird::dDllUnloadTID) { if (!Firebird::dDllUnloadTID) {
WaitForSingleObject(handle, 500); WaitForSingleObject(handle, 500);
} }
skipping to change at line 343 skipping to change at line 357
TerminateThread(handle, -1); TerminateThread(handle, -1);
CloseHandle(handle); CloseHandle(handle);
handle = 0; handle = 0;
} }
ThreadId Thread::getId() ThreadId Thread::getId()
{ {
return GetCurrentThreadId(); return GetCurrentThreadId();
} }
bool Thread::isCurrent(const ThreadId threadId)
{
return GetCurrentThreadId() == threadId;
}
void Thread::sleep(unsigned milliseconds) void Thread::sleep(unsigned milliseconds)
{ {
SleepEx(milliseconds, FALSE); SleepEx(milliseconds, FALSE);
} }
void Thread::yield() void Thread::yield()
{ {
SleepEx(0, FALSE); SleepEx(0, FALSE);
} }
#endif // WIN_NT #endif // WIN_NT
#ifndef START_THREAD #ifndef START_THREAD
void Thread::start(ThreadEntryPoint* routine, void* arg, int priority_arg, Handl e* p_handle) ThreadId Thread::start(ThreadEntryPoint* routine, void* arg, int priority_arg, H andle* p_handle)
{ {
/************************************** /**************************************
* *
* t h r e a d _ s t a r t ( G e n e r i c ) * t h r e a d _ s t a r t ( G e n e r i c )
* *
************************************** **************************************
* *
* Functional description * Functional description
* Wrong attempt to start a new thread. * Wrong attempt to start a new thread.
* *
**************************************/ **************************************/
fb_assert(false);
return 0;
} }
void Thread::waitForCompletion(Handle&) void Thread::waitForCompletion(Handle&)
{ {
} }
void Thread::kill(Handle&) void Thread::kill(Handle&)
{ {
} }
 End of changes. 10 change blocks. 
5 lines changed or deleted 26 lines changed or added

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