"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/common/classes/Synchronize.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.

Synchronize.cpp  (Firebird-3.0.2.32703-0.tar.bz2):Synchronize.cpp  (Firebird-3.0.4.33054-0.tar.bz2)
skipping to change at line 34 skipping to change at line 34
* All Rights Reserved. * All Rights Reserved.
* *
* The Code was ported into Firebird Open Source RDBMS project by * The Code was ported into Firebird Open Source RDBMS project by
* Vladyslav Khorsun at 2010 * Vladyslav Khorsun at 2010
* *
* Contributor(s): * Contributor(s):
*/ */
#include "firebird.h" #include "firebird.h"
#include "fb_tls.h" #include "fb_tls.h"
#include "init.h"
#include "../ThreadStart.h" #include "../ThreadStart.h"
#include "SyncObject.h" #include "SyncObject.h"
#include "Synchronize.h" #include "Synchronize.h"
#ifdef TIME_WITH_SYS_TIME #ifdef TIME_WITH_SYS_TIME
# include <sys/time.h> # include <sys/time.h>
# include <time.h> # include <time.h>
#else #else
# ifdef HAVE_SYS_TIME_H # ifdef HAVE_SYS_TIME_H
# include <sys/time.h> # include <sys/time.h>
skipping to change at line 184 skipping to change at line 185
system_call_failed::raise("pthread_mutex_unlock", ret); system_call_failed::raise("pthread_mutex_unlock", ret);
#endif #endif
} }
void Synchronize::shutdown() void Synchronize::shutdown()
{ {
shutdownInProgress = true; shutdownInProgress = true;
wake(); wake();
} }
class ThreadSyncInstance : public ThreadSync
{
typedef InstanceControl::InstanceLink<ThreadSyncInstance, InstanceControl
::PRIORITY_REGULAR> Link;
public:
ThreadSyncInstance(const char* desc)
: ThreadSync(desc)
{
m_link = FB_NEW Link(this);
}
virtual ~ThreadSyncInstance()
{
if (m_link)
{
m_link->remove();
delete m_link;
}
}
// Used at InstanceControl::dtor
void dtor()
{
m_link = NULL;
delete this;
}
private:
Link* m_link;
};
/// ThreadSync /// ThreadSync
TLS_DECLARE(ThreadSync*, threadIndex); TLS_DECLARE(ThreadSync*, threadIndex);
ThreadSync::ThreadSync(const char* desc) ThreadSync::ThreadSync(const char* desc)
: threadId(getCurrentThreadId()), nextWaiting(NULL), prevWaiting(NULL), : threadId(getCurrentThreadId()), nextWaiting(NULL), prevWaiting(NULL),
lockType(SYNC_NONE), lockGranted(false), lockPending(NULL), locks(NULL) , lockType(SYNC_NONE), lockGranted(false), lockPending(NULL), locks(NULL) ,
description(desc) description(desc)
{ {
setThread(this); setThread(this);
skipping to change at line 212 skipping to change at line 244
{ {
return TLS_GET(threadIndex); return TLS_GET(threadIndex);
} }
ThreadSync* ThreadSync::getThread(const char* desc) ThreadSync* ThreadSync::getThread(const char* desc)
{ {
ThreadSync* thread = findThread(); ThreadSync* thread = findThread();
if (!thread) if (!thread)
{ {
thread = FB_NEW ThreadSync(desc); thread = FB_NEW ThreadSyncInstance(desc);
fb_assert(thread == findThread()); fb_assert(thread == findThread());
} }
return thread; return thread;
} }
void ThreadSync::setThread(ThreadSync* thread) void ThreadSync::setThread(ThreadSync* thread)
{ {
if (thread != NULL)
{
ThreadSync* other = findThread();
fb_assert(other == NULL);
}
TLS_SET(threadIndex, thread); TLS_SET(threadIndex, thread);
} }
ThreadId ThreadSync::getCurrentThreadId() ThreadId ThreadSync::getCurrentThreadId()
{ {
return getThreadId(); return getThreadId();
} }
const char* ThreadSync::getWhere() const const char* ThreadSync::getWhere() const
{ {
 End of changes. 4 change blocks. 
1 lines changed or deleted 40 lines changed or added

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