2009-11-09 16:26 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/config/win/bcc.mk
* increased library page size for 64 to 96
* harbour/src/vm/thread.c
* harbour/include/hbthread.h
% removed 'BOOL fSync' parameter from hb_threadMutexCreate().
This parameter was added in the past to emulate xbase++ behavior
when oSignal:wait() is called from SYNC method but real life tests
shows that such feature works in xbase++ in different way then
it was initially described and Harbour code was updated to use
different solution making above parameter unusable.
* harbour/src/vm/hvm.c
* harbour/src/vm/thread.c
* harbour/src/vm/classes.c
* harbour/src/rtl/hbgtcore.c
* harbour/contrib/hbnetio/netiocli.c
* harbour/contrib/hbqt/hbqt_slots.cpp
* updated to use hb_threadMutexCreate() without parameters
This commit is contained in:
@@ -17,6 +17,27 @@
|
||||
past entries belonging to author(s): Viktor Szakats.
|
||||
*/
|
||||
|
||||
2009-11-09 16:26 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/config/win/bcc.mk
|
||||
* increased library page size for 64 to 96
|
||||
|
||||
* harbour/src/vm/thread.c
|
||||
* harbour/include/hbthread.h
|
||||
% removed 'BOOL fSync' parameter from hb_threadMutexCreate().
|
||||
This parameter was added in the past to emulate xbase++ behavior
|
||||
when oSignal:wait() is called from SYNC method but real life tests
|
||||
shows that such feature works in xbase++ in different way then
|
||||
it was initially described and Harbour code was updated to use
|
||||
different solution making above parameter unusable.
|
||||
|
||||
* harbour/src/vm/hvm.c
|
||||
* harbour/src/vm/thread.c
|
||||
* harbour/src/vm/classes.c
|
||||
* harbour/src/rtl/hbgtcore.c
|
||||
* harbour/contrib/hbnetio/netiocli.c
|
||||
* harbour/contrib/hbqt/hbqt_slots.cpp
|
||||
* updated to use hb_threadMutexCreate() without parameters
|
||||
|
||||
2009-11-09 13:23 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
|
||||
* harbour/src/rtl/cdpapi.c
|
||||
! fixed very bad typo in new CDP API code - hb_cdpnDup2() was not updating
|
||||
|
||||
@@ -59,7 +59,7 @@ LDLIBS += $(foreach lib,$(SYSLIBS),$(lib)$(LIB_EXT))
|
||||
LDFLAGS += $(LIBPATHS)
|
||||
|
||||
AR := tlib.exe
|
||||
ARFLAGS := /P64
|
||||
ARFLAGS := /P96
|
||||
AR_RULE = $(AR) $(ARFLAGS) $(HB_USER_AFLAGS) "$(subst /,\,$(LIB_DIR)/$@)" $(foreach file,$(?F),-+$(file))
|
||||
|
||||
ifneq ($(HB_SHELL),sh)
|
||||
|
||||
@@ -209,7 +209,7 @@ static PHB_CONCLI s_fileConNew( HB_SOCKET sd, const char * pszServer,
|
||||
iLen = ( int ) strlen( pszServer );
|
||||
conn = ( PHB_CONCLI ) hb_xgrab( sizeof( HB_CONCLI ) + iLen );
|
||||
hb_atomic_set( &conn->used, 1 );
|
||||
conn->mutex = hb_threadMutexCreate( FALSE );
|
||||
conn->mutex = hb_threadMutexCreate();
|
||||
conn->sd = sd;
|
||||
conn->next = NULL;
|
||||
conn->timeout = iTimeOut;
|
||||
|
||||
@@ -2461,7 +2461,7 @@ HB_FUNC( QT_MUTEXCREATE )
|
||||
{
|
||||
if( s_mutex == NULL )
|
||||
{
|
||||
s_mutex = hb_threadMutexCreate( FALSE );
|
||||
s_mutex = hb_threadMutexCreate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -413,7 +413,7 @@ extern BOOL hb_threadJoin( HB_THREAD_HANDLE th_h );
|
||||
extern BOOL hb_threadDetach( HB_THREAD_HANDLE th_h );
|
||||
|
||||
/* used by .prg code */
|
||||
extern PHB_ITEM hb_threadMutexCreate( BOOL fSync );
|
||||
extern PHB_ITEM hb_threadMutexCreate( void );
|
||||
extern BOOL hb_threadMutexLock( PHB_ITEM pItem );
|
||||
extern BOOL hb_threadMutexTimedLock( PHB_ITEM pItem, ULONG ulMilliSec );
|
||||
extern BOOL hb_threadMutexUnlock( PHB_ITEM pItem );
|
||||
|
||||
@@ -109,7 +109,7 @@ static void hb_gt_def_BaseInit( PHB_GT_BASE pGT )
|
||||
pGT->inkeyBuffer = pGT->defaultKeyBuffer;
|
||||
pGT->inkeyBufferSize = HB_DEFAULT_INKEY_BUFSIZE;
|
||||
|
||||
pGT->pMutex = hb_threadMutexCreate( TRUE );
|
||||
pGT->pMutex = hb_threadMutexCreate();
|
||||
if( pGT->pMutex )
|
||||
hb_gcUnlock( pGT->pMutex );
|
||||
}
|
||||
|
||||
@@ -926,7 +926,7 @@ static void hb_clsCopyClass( PCLASS pClsDst, PCLASS pClsSrc )
|
||||
pClsDst->uiMutexOffset = pClsSrc->uiMutexOffset;
|
||||
pClsDst->ulOpFlags = pClsSrc->ulOpFlags;
|
||||
if( pClsSrc->pMutex )
|
||||
pClsDst->pMutex = hb_threadMutexCreate( FALSE );
|
||||
pClsDst->pMutex = hb_threadMutexCreate();
|
||||
|
||||
if( pClsSrc->uiInitDatas )
|
||||
{
|
||||
@@ -1056,7 +1056,7 @@ void hb_clsInit( void )
|
||||
s_pClasses[ 0 ] = NULL;
|
||||
|
||||
#if defined( HB_MT_VM )
|
||||
s_pClassMtx = hb_threadMutexCreate( FALSE );
|
||||
s_pClassMtx = hb_threadMutexCreate();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -2990,7 +2990,7 @@ static BOOL hb_clsAddMsg( USHORT uiClass, const char * szMessage,
|
||||
if( uiScope & HB_OO_CLSTP_CLASS )
|
||||
{
|
||||
if( !pClass->pMutex )
|
||||
pClass->pMutex = hb_threadMutexCreate( FALSE );
|
||||
pClass->pMutex = hb_threadMutexCreate();
|
||||
pNewMeth->pFuncSym = &s___msgSyncClass;
|
||||
}
|
||||
else
|
||||
@@ -3352,7 +3352,7 @@ static USHORT hb_clsNew( const char * szClassName, USHORT uiDatas,
|
||||
if( pNewCls->uiMutexOffset )
|
||||
pNewCls->uiMutexOffset = pNewCls->uiDatas + 1;
|
||||
if( fClsMutex && !pNewCls->pMutex )
|
||||
pNewCls->pMutex = hb_threadMutexCreate( FALSE );
|
||||
pNewCls->pMutex = hb_threadMutexCreate();
|
||||
|
||||
return s_uiClasses;
|
||||
}
|
||||
@@ -3478,7 +3478,7 @@ static PHB_ITEM hb_clsInst( USHORT uiClass )
|
||||
|
||||
if( pClass->uiMutexOffset )
|
||||
{
|
||||
PHB_ITEM pMutex = hb_threadMutexCreate( FALSE );
|
||||
PHB_ITEM pMutex = hb_threadMutexCreate();
|
||||
hb_arraySet( pSelf, pClass->uiMutexOffset, pMutex );
|
||||
hb_itemRelease( pMutex );
|
||||
}
|
||||
|
||||
@@ -914,7 +914,7 @@ void hb_vmInit( BOOL bStartMainProc )
|
||||
#if defined( HB_MT_VM )
|
||||
hb_threadInit();
|
||||
hb_vmStackInit( hb_threadStateNew() ); /* initialize HVM thread stack */
|
||||
s_pSymbolsMtx = hb_threadMutexCreate( FALSE );
|
||||
s_pSymbolsMtx = hb_threadMutexCreate();
|
||||
#else
|
||||
hb_stackInit(); /* initialize HVM stack */
|
||||
#endif /* HB_MT_VM */
|
||||
|
||||
@@ -1464,7 +1464,7 @@ HB_FUNC( HB_THREADONCE )
|
||||
hb_threadInit();
|
||||
HB_CRITICAL_LOCK( s_once_mtx );
|
||||
if( !s_pOnceMutex )
|
||||
s_pOnceMutex = hb_threadMutexCreate( FALSE );
|
||||
s_pOnceMutex = hb_threadMutexCreate();
|
||||
HB_CRITICAL_UNLOCK( s_once_mtx );
|
||||
}
|
||||
if( hb_threadMutexLock( s_pOnceMutex ) )
|
||||
@@ -1498,7 +1498,6 @@ HB_FUNC( HB_THREADONCE )
|
||||
|
||||
typedef struct _HB_MUTEX
|
||||
{
|
||||
BOOL fSync;
|
||||
int lock_count;
|
||||
int lockers;
|
||||
int waiters;
|
||||
@@ -1512,15 +1511,6 @@ typedef struct _HB_MUTEX
|
||||
}
|
||||
HB_MUTEX, * PHB_MUTEX;
|
||||
|
||||
typedef struct _HB_MTXLST
|
||||
{
|
||||
int lock_count;
|
||||
PHB_MUTEX pMutex;
|
||||
struct _HB_MTXLST * pNext;
|
||||
}
|
||||
HB_MTXLST, * PHB_MTXLST;
|
||||
|
||||
static PHB_MUTEX s_pSyncList = NULL;
|
||||
static PHB_MUTEX s_pMutexList = NULL;
|
||||
|
||||
static void hb_mutexLink( PHB_MUTEX *pList, PHB_MUTEX pItem )
|
||||
@@ -1551,12 +1541,12 @@ static void hb_mutexUnlink( PHB_MUTEX *pList, PHB_MUTEX pItem )
|
||||
}
|
||||
|
||||
#if defined( HB_MT_VM )
|
||||
static void hb_mutexListUnlock( PHB_MUTEX * pList, PHB_MTXLST * pStore )
|
||||
void hb_threadMutexUnlockAll( void )
|
||||
{
|
||||
HB_CRITICAL_LOCK( s_mutexlst_mtx );
|
||||
if( *pList )
|
||||
if( s_pMutexList )
|
||||
{
|
||||
PHB_MUTEX pMutex = *pList;
|
||||
PHB_MUTEX pMutex = s_pMutexList;
|
||||
do
|
||||
{
|
||||
if( HB_THREAD_EQUAL( pMutex->owner, HB_THREAD_SELF() ) )
|
||||
@@ -1564,14 +1554,6 @@ static void hb_mutexListUnlock( PHB_MUTEX * pList, PHB_MTXLST * pStore )
|
||||
HB_CRITICAL_LOCK( pMutex->mutex );
|
||||
if( HB_THREAD_EQUAL( pMutex->owner, HB_THREAD_SELF() ) )
|
||||
{
|
||||
if( pStore )
|
||||
{
|
||||
*pStore = ( PHB_MTXLST ) hb_xgrab( sizeof( HB_MTXLST ) );
|
||||
(*pStore)->lock_count = pMutex->lock_count;
|
||||
(*pStore)->pMutex = pMutex;
|
||||
pStore = &(*pStore)->pNext;
|
||||
*pStore = NULL;
|
||||
}
|
||||
pMutex->lock_count = 0;
|
||||
pMutex->owner = ( HB_THREAD_ID ) 0;
|
||||
if( pMutex->lockers )
|
||||
@@ -1581,51 +1563,11 @@ static void hb_mutexListUnlock( PHB_MUTEX * pList, PHB_MTXLST * pStore )
|
||||
}
|
||||
pMutex = pMutex->pNext;
|
||||
}
|
||||
while( pMutex != *pList );
|
||||
while( pMutex != s_pMutexList );
|
||||
}
|
||||
HB_CRITICAL_UNLOCK( s_mutexlst_mtx );
|
||||
}
|
||||
|
||||
static void hb_mutexListLock( PHB_MTXLST pList )
|
||||
{
|
||||
while( pList )
|
||||
{
|
||||
PHB_MUTEX pMutex = pList->pMutex;
|
||||
|
||||
HB_CRITICAL_LOCK( pMutex->mutex );
|
||||
while( pMutex->lock_count != 0 )
|
||||
{
|
||||
pMutex->lockers++;
|
||||
#if defined( HB_PTHREAD_API )
|
||||
pthread_cond_wait( &pMutex->cond_l, &pMutex->mutex );
|
||||
#elif defined( HB_TASK_THREAD )
|
||||
hb_taskWait( &pMutex->cond_l, &pMutex->mutex, HB_TASK_INFINITE_WAIT );
|
||||
#elif defined( HB_COND_HARBOUR_SUPPORT )
|
||||
_hb_thread_cond_wait( &pMutex->cond_l, &pMutex->mutex, HB_THREAD_INFINITE_WAIT );
|
||||
#else
|
||||
HB_CRITICAL_UNLOCK( pMutex->mutex );
|
||||
( void ) HB_COND_WAIT( pMutex->cond_l );
|
||||
HB_CRITICAL_LOCK( pMutex->mutex );
|
||||
#endif
|
||||
pMutex->lockers--;
|
||||
}
|
||||
pMutex->lock_count = pList->lock_count;
|
||||
pMutex->owner = HB_THREAD_SELF();
|
||||
HB_CRITICAL_UNLOCK( pMutex->mutex );
|
||||
{
|
||||
PHB_MTXLST pFree = pList;
|
||||
pList = pList->pNext;
|
||||
hb_xfree( pFree );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void hb_threadMutexUnlockAll( void )
|
||||
{
|
||||
hb_mutexListUnlock( &s_pMutexList, NULL );
|
||||
hb_mutexListUnlock( &s_pSyncList, NULL );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
static HB_GARBAGE_FUNC( hb_mutexDestructor )
|
||||
@@ -1634,10 +1576,10 @@ static HB_GARBAGE_FUNC( hb_mutexDestructor )
|
||||
|
||||
#if defined( HB_MT_VM )
|
||||
HB_CRITICAL_LOCK( s_mutexlst_mtx );
|
||||
hb_mutexUnlink( pMutex->fSync ? &s_pSyncList : &s_pMutexList, pMutex );
|
||||
hb_mutexUnlink( &s_pMutexList, pMutex );
|
||||
HB_CRITICAL_UNLOCK( s_mutexlst_mtx );
|
||||
#else
|
||||
hb_mutexUnlink( pMutex->fSync ? &s_pSyncList : &s_pMutexList, pMutex );
|
||||
hb_mutexUnlink( &s_pMutexList, pMutex );
|
||||
#endif
|
||||
|
||||
if( pMutex->events )
|
||||
@@ -1684,7 +1626,7 @@ static PHB_ITEM hb_mutexParam( int iParam )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PHB_ITEM hb_threadMutexCreate( BOOL fSync )
|
||||
PHB_ITEM hb_threadMutexCreate( void )
|
||||
{
|
||||
PHB_MUTEX pMutex;
|
||||
PHB_ITEM pItem;
|
||||
@@ -1704,13 +1646,12 @@ PHB_ITEM hb_threadMutexCreate( BOOL fSync )
|
||||
# endif
|
||||
#endif
|
||||
|
||||
pMutex->fSync = fSync;
|
||||
#if defined( HB_MT_VM )
|
||||
HB_CRITICAL_LOCK( s_mutexlst_mtx );
|
||||
hb_mutexLink( fSync ? &s_pSyncList : &s_pMutexList, pMutex );
|
||||
hb_mutexLink( &s_pMutexList, pMutex );
|
||||
HB_CRITICAL_UNLOCK( s_mutexlst_mtx );
|
||||
#else
|
||||
hb_mutexLink( fSync ? &s_pSyncList : &s_pMutexList, pMutex );
|
||||
hb_mutexLink( &s_pMutexList, pMutex );
|
||||
#endif
|
||||
|
||||
return pItem;
|
||||
@@ -1782,7 +1723,7 @@ BOOL hb_threadMutexSyncWait( PHB_ITEM pItemMtx, ULONG ulMilliSec,
|
||||
|
||||
if( ulMilliSec && !( pMutex->events && hb_arrayLen( pMutex->events ) > 0 ) )
|
||||
{
|
||||
/* release own locks from sync mutex */
|
||||
/* release own lock from sync mutex */
|
||||
if( pSyncMutex && HB_THREAD_EQUAL( pSyncMutex->owner, HB_THREAD_SELF() ) )
|
||||
{
|
||||
HB_CRITICAL_LOCK( pSyncMutex->mutex );
|
||||
@@ -1856,7 +1797,7 @@ BOOL hb_threadMutexSyncWait( PHB_ITEM pItemMtx, ULONG ulMilliSec,
|
||||
|
||||
HB_CRITICAL_UNLOCK( pMutex->mutex );
|
||||
|
||||
/* restore the own locks on sync mutex if necessary */
|
||||
/* restore the own lock on sync mutex if necessary */
|
||||
if( lock_count )
|
||||
{
|
||||
HB_CRITICAL_LOCK( pSyncMutex->mutex );
|
||||
@@ -2179,8 +2120,6 @@ PHB_ITEM hb_threadMutexSubscribe( PHB_ITEM pItem, BOOL fClear )
|
||||
}
|
||||
}
|
||||
#else
|
||||
PHB_MTXLST pSyncList = NULL;
|
||||
BOOL fSync = TRUE;
|
||||
int lock_count = 0;
|
||||
|
||||
hb_vmUnlock();
|
||||
@@ -2202,15 +2141,6 @@ PHB_ITEM hb_threadMutexSubscribe( PHB_ITEM pItem, BOOL fClear )
|
||||
|
||||
while( !pMutex->events || hb_arrayLen( pMutex->events ) == 0 )
|
||||
{
|
||||
if( fSync )
|
||||
{
|
||||
/* SYNC method mutexes cannot be used for subscribe so it's safe
|
||||
* to unlock them when THIS mutex is internally locked
|
||||
*/
|
||||
hb_mutexListUnlock( &s_pSyncList, &pSyncList );
|
||||
fSync = FALSE;
|
||||
}
|
||||
|
||||
pMutex->waiters++;
|
||||
# if defined( HB_PTHREAD_API )
|
||||
pthread_cond_wait( &pMutex->cond_w, &pMutex->mutex );
|
||||
@@ -2262,8 +2192,6 @@ PHB_ITEM hb_threadMutexSubscribe( PHB_ITEM pItem, BOOL fClear )
|
||||
|
||||
HB_CRITICAL_UNLOCK( pMutex->mutex );
|
||||
|
||||
hb_mutexListLock( pSyncList );
|
||||
|
||||
hb_vmLock();
|
||||
#endif
|
||||
}
|
||||
@@ -2293,7 +2221,6 @@ PHB_ITEM hb_threadMutexTimedSubscribe( PHB_ITEM pItem, ULONG ulMilliSec, BOOL fC
|
||||
}
|
||||
}
|
||||
#else
|
||||
PHB_MTXLST pSyncList = NULL;
|
||||
int lock_count = 0;
|
||||
|
||||
hb_vmUnlock();
|
||||
@@ -2315,11 +2242,6 @@ PHB_ITEM hb_threadMutexTimedSubscribe( PHB_ITEM pItem, ULONG ulMilliSec, BOOL fC
|
||||
HB_COND_SIGNAL( pMutex->cond_l );
|
||||
}
|
||||
|
||||
/* SYNC method mutexes cannot be used for subscribe so it's safe
|
||||
* to unlock them when THIS mutex is internally locked
|
||||
*/
|
||||
hb_mutexListUnlock( &s_pSyncList, &pSyncList );
|
||||
|
||||
pMutex->waiters++;
|
||||
# if defined( HB_PTHREAD_API )
|
||||
{
|
||||
@@ -2388,8 +2310,6 @@ PHB_ITEM hb_threadMutexTimedSubscribe( PHB_ITEM pItem, ULONG ulMilliSec, BOOL fC
|
||||
|
||||
HB_CRITICAL_UNLOCK( pMutex->mutex );
|
||||
|
||||
hb_mutexListLock( pSyncList );
|
||||
|
||||
hb_vmLock();
|
||||
#endif
|
||||
}
|
||||
@@ -2398,7 +2318,7 @@ PHB_ITEM hb_threadMutexTimedSubscribe( PHB_ITEM pItem, ULONG ulMilliSec, BOOL fC
|
||||
|
||||
HB_FUNC( HB_MUTEXCREATE )
|
||||
{
|
||||
hb_itemReturnRelease( hb_threadMutexCreate( FALSE ) );
|
||||
hb_itemReturnRelease( hb_threadMutexCreate() );
|
||||
}
|
||||
|
||||
HB_FUNC( HB_MUTEXLOCK )
|
||||
|
||||
Reference in New Issue
Block a user