From: <ust...@us...> - 2008-10-03 15:34:25
|
Revision: 2927 http://clucene.svn.sourceforge.net/clucene/?rev=2927&view=rev Author: ustramooner Date: 2008-10-03 15:34:14 +0000 (Fri, 03 Oct 2008) Log Message: ----------- threadlocal fix progress Modified Paths: -------------- branches/lucene2_3_2/src/core/CLucene/index/TermInfosReader.cpp branches/lucene2_3_2/src/core/CLucene/util/ThreadLocal.cpp Modified: branches/lucene2_3_2/src/core/CLucene/index/TermInfosReader.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/index/TermInfosReader.cpp 2008-10-03 14:55:06 UTC (rev 2926) +++ branches/lucene2_3_2/src/core/CLucene/index/TermInfosReader.cpp 2008-10-03 15:34:14 UTC (rev 2927) @@ -152,7 +152,7 @@ //Delete the IndexInput _CLDELETE(is); } - enumerators.set(NULL); + enumerators.setNull(); } int64_t TermInfosReader::size() const{ Modified: branches/lucene2_3_2/src/core/CLucene/util/ThreadLocal.cpp =================================================================== --- branches/lucene2_3_2/src/core/CLucene/util/ThreadLocal.cpp 2008-10-03 14:55:06 UTC (rev 2926) +++ branches/lucene2_3_2/src/core/CLucene/util/ThreadLocal.cpp 2008-10-03 15:34:14 UTC (rev 2927) @@ -26,10 +26,10 @@ #define INIT_THREAD(ret) ret=true extern "C"{ #ifndef _WINBASE_ - __declspec(dllimport) _cl_dword_t __stdcall TlsAlloc( ); + /*__declspec(dllimport) _cl_dword_t __stdcall TlsAlloc( ); __declspec(dllimport) void* __stdcall TlsGetValue(_cl_dword_t dwTlsIndex ); __declspec(dllimport) bool __stdcall TlsSetValue( _cl_dword_t dwTlsIndex, void* lpTlsValue ); - __declspec(dllimport) bool __stdcall TlsFree( _cl_dword_t dwTlsIndex ); + __declspec(dllimport) bool __stdcall TlsFree( _cl_dword_t dwTlsIndex );*/ #define DLL_THREAD_DETACH 3 #endif //_WINBASE_ @@ -38,10 +38,10 @@ _cl_dword_t fdwReason, // reason called void*) // reserved { - if ( fdwReason == DLL_THREAD_DETACH ) - _ThreadLocal::UnregisterCurrentThread(); + if ( fdwReason == DLL_THREAD_DETACH ) + _ThreadLocal::UnregisterCurrentThread(); - return TRUE; + return true; } } #elif defined(_CL_HAVE_PTHREAD) @@ -80,7 +80,7 @@ typedef CL_NS ( util ) ::CLMultiMap<const _LUCENE_THREADID_TYPE, ThreadLocals*, CL_NS ( util ) ::CLuceneThreadIdCompare, CL_NS ( util ) ::Deletor::ConstNullVal<_LUCENE_THREADID_TYPE>, - CL_NS ( util ) ::Deletor::ConstNullVal<ThreadLocals*> > ThreadDataType; + CL_NS ( util ) ::Deletor::Object<ThreadLocals> > ThreadDataType; static ThreadDataType* threadData; #ifdef _LUCENE_THREADMUTEX @@ -156,6 +156,10 @@ void _ThreadLocal::set ( void* t ) { + if ( t == NULL ){ + setNull(); + return; + } //make sure we have a threadlocal context (for cleanup) bool ret; INIT_THREAD(ret); @@ -174,12 +178,13 @@ SCOPED_LOCK_MUTEX ( *threadData_LOCK ); if ( threadData == NULL ) - threadData = _CLNEW ThreadDataType ( false,false ); + threadData = _CLNEW ThreadDataType ( false, true ); ThreadLocals* threadLocals = threadData->get(id); if ( threadLocals == NULL ){ threadLocals = _CLNEW ThreadLocals; threadData->put(id,threadLocals); + printf("starting thread %d\n",(int)id); } threadLocals->add(this); } @@ -207,13 +212,18 @@ _LUCENE_THREADID_TYPE id = _LUCENE_CURRTHREADID; SCOPED_LOCK_MUTEX ( *threadData_LOCK ); - ThreadLocals* threadLocals = threadData->get(id); - threadLocals->UnregisterThread(); + ThreadDataType::iterator itr = threadData->find(id); + if ( itr != threadData->end() ){ + ThreadLocals* threadLocals = itr->second; + threadLocals->UnregisterThread(); + threadData->removeitr(itr); + } } void _ThreadLocal::_shutdown() { - + _CLDELETE(threadData_LOCK); + _CLDELETE(threadData); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |