2008-09-22 02:34 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/include/hbvm.h
  * harbour/source/vm/hvm.c
  * harbour/source/vm/thread.c
    + added .prg function hb_threadSelf() -> <pThID> | NIL
      It returns thread ID pointer variable or NIL when thread was
      registered without it (main thread and some 3-rd party threads
      created by C API)

  * harbour/source/vm/hvm.c
    * protect s_InitFunctions and s_ExitFunctions by mutex

  * harbour/source/common/hbverdsp.c
    * use hb_verBuildDate() instead of __DATE__ and __TIME__ in
      hb_verBuildInfo() function to report the same time in both
      cases.
This commit is contained in:
Przemyslaw Czerpak
2008-09-22 00:34:52 +00:00
parent c1c574142e
commit a8aac5cae5
5 changed files with 57 additions and 17 deletions

View File

@@ -8,6 +8,23 @@
2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org)
*/
2008-09-22 02:34 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbvm.h
* harbour/source/vm/hvm.c
* harbour/source/vm/thread.c
+ added .prg function hb_threadSelf() -> <pThID> | NIL
It returns thread ID pointer variable or NIL when thread was
registered without it (main thread and some 3-rd party threads
created by C API)
* harbour/source/vm/hvm.c
* protect s_InitFunctions and s_ExitFunctions by mutex
* harbour/source/common/hbverdsp.c
* use hb_verBuildDate() instead of __DATE__ and __TIME__ in
hb_verBuildInfo() function to report the same time in both
cases.
2008-09-21 23:03 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbapi.h
* harbour/source/vm/arrays.c

View File

@@ -164,6 +164,7 @@ extern HB_EXPORT void hb_vmThreadQuit( void ); /* destroy local thread HVM s
extern HB_EXPORT void hb_vmThreadQuitRequest( void * ); /* send QUIT request to given thread */
extern HB_EXPORT void hb_vmWaitForThreads( void ); /* wait for all threads to terminate can be called only by main HVM thread */
extern HB_EXPORT void hb_vmTerminateThreads( void ); /* send QUIT request to all threads except current one and wait for their termination, should be called only by main HVM thread */
extern HB_EXPORT void * hb_vmThreadState( void );
/* various flags for supported features */
#define HB_VMFLAG_HARBOUR 1 /* enable Harbour extension */

View File

@@ -93,25 +93,21 @@ void hb_verBuildInfo( void )
hb_conOutErr( hb_conNewLine(), 0 );
hb_conOutErr( "Built on: ", 0 );
hb_conOutErr( __DATE__, 0 );
hb_conOutErr( " ", 0 );
hb_conOutErr( __TIME__, 0 );
{
char * pszBuildDate = hb_verBuildDate();
hb_conOutErr( "Built on: ", 0 );
hb_conOutErr( pszBuildDate, 0 );
hb_conOutErr( hb_conNewLine(), 0 );
hb_xfree( pszBuildDate );
}
hb_conOutErr( "Last ChangeLog entry: ", 0 );
hb_conOutErr( hb_verSvnLastEntry(), 0 );
hb_conOutErr( hb_conNewLine(), 0 );
{
const char * pszLastEntry = hb_verSvnLastEntry();
hb_conOutErr( "Last ChangeLog entry: ", 0 );
hb_conOutErr( pszLastEntry, 0 );
hb_conOutErr( hb_conNewLine(), 0 );
}
{
const char * pszLogID = hb_verSvnChangeLogID();
hb_conOutErr( "ChangeLog SVN version: ", 0 );
hb_conOutErr( pszLogID, 0 );
hb_conOutErr( hb_conNewLine(), 0 );
}
hb_conOutErr( "ChangeLog SVN version: ", 0 );
hb_conOutErr( hb_verSvnChangeLogID(), 0 );
hb_conOutErr( hb_conNewLine(), 0 );
{
const char * pszFlags = hb_verFlagsPRG();

View File

@@ -221,6 +221,13 @@ static void hb_vmMsgIndexReference( PHB_ITEM pRefer, PHB_ITEM pObject, PHB_IT
#if defined( HB_MT_VM )
static int volatile hb_vmThreadRequest = 0;
static void hb_vmRequestTest( void );
static HB_CRITICAL_NEW( s_atInitMtx );
# define HB_ATINIT_LOCK hb_threadEnterCriticalSection( &s_atInitMtx );
# define HB_ATINIT_UNLOCK hb_threadLeaveCriticalSection( &s_atInitMtx );
#else
# define HB_ATINIT_LOCK
# define HB_ATINIT_UNLOCK
#endif
#ifndef HB_NO_PROFILER
@@ -290,8 +297,10 @@ HB_EXPORT void hb_vmAtInit( HB_INIT_FUNC pFunc, void * cargo )
pLst->pFunc = pFunc;
pLst->cargo = cargo;
HB_ATINIT_LOCK
pLst->pNext = s_InitFunctions;
s_InitFunctions = pLst;
HB_ATINIT_UNLOCK
}
HB_EXPORT void hb_vmAtExit( HB_INIT_FUNC pFunc, void * cargo )
@@ -300,8 +309,10 @@ HB_EXPORT void hb_vmAtExit( HB_INIT_FUNC pFunc, void * cargo )
pLst->pFunc = pFunc;
pLst->cargo = cargo;
HB_ATINIT_LOCK
pLst->pNext = s_ExitFunctions;
s_ExitFunctions = pLst;
HB_ATINIT_UNLOCK
}
static void hb_vmCleanModuleFunctions( void )
@@ -560,6 +571,13 @@ void hb_vmWaitForThreads( void )
}
}
void * hb_vmThreadState( void )
{
HB_TRACE(HB_TR_DEBUG, ("hb_vmThreadState()"));
return ( void * ) ( ( PHB_VM_STACKLST ) hb_stackList() )->pState;
}
static void hb_vmStackAdd( PHB_THREADSTATE pState )
{
PHB_VM_STACKLST pStack;

View File

@@ -639,6 +639,14 @@ HB_FUNC( HB_THREADSTART )
}
}
HB_FUNC( HB_THREADSELF )
{
#if defined( HB_MT_VM )
PHB_THREADSTATE pThread = ( PHB_THREADSTATE ) hb_vmThreadState();
hb_itemReturn( pThread->pThItm );
#endif
}
HB_FUNC( HB_THREADJOIN )
{
PHB_THREADSTATE pThread = hb_thParam( 1 );