2009-01-19 22:17 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/source/vm/hvm.c
    * clone arrays and hash tables instead of coping when thread static
      variable is initialized

  + harbour/tests/mt/mttest12.prg
    + added demonstration/test code which illustrates thread static
      variables initialization
This commit is contained in:
Przemyslaw Czerpak
2009-01-19 21:13:58 +00:00
parent 4f94ab2609
commit 603ad8a1fd
3 changed files with 64 additions and 1 deletions

View File

@@ -8,6 +8,15 @@
2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org)
*/
2009-01-19 22:17 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/source/vm/hvm.c
* clone arrays and hash tables instead of coping when thread static
variable is initialized
+ harbour/tests/mt/mttest12.prg
+ added demonstration/test code which illustrates thread static
variables initialization
2009-01-19 21:38 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/contrib/hbct/ctwin.c
* harbour/contrib/hbct/ctwin.h

View File

@@ -5984,7 +5984,14 @@ static PHB_ITEM hb_vmTSVRefRead( PHB_ITEM pRefer )
if( !pItem )
{
pItem = ( PHB_ITEM ) hb_stackGetTSD( &pTSVRef->threadData );
hb_itemCopy( pItem, &pTSVRef->source );
if( HB_ITEM_TYPERAW( &pTSVRef->source ) & ( HB_IT_ARRAY | HB_IT_HASH ) )
{
PHB_ITEM pClone = hb_itemClone( &pTSVRef->source );
hb_itemCopy( pItem, pClone );
hb_itemRelease( pClone );
}
else
hb_itemCopy( pItem, &pTSVRef->source );
}
return pItem;
}

View File

@@ -0,0 +1,47 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* demonstration/test code for thread static variables
*
* Copyright 2009 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
* www - http://www.harbour-project.org
*
*/
thread static s_var1 := { "A", "B", "C" }
thread static s_var2 := { "A" => "qwe", "B" => "asd" }
thread static s_var3 := 1235.567
thread static s_var4 := "text"
proc main()
testvar("initial main thread values")
aadd( s_var1, "X" )
s_var2[ "X" ] := "zxc"
s_var3 += 100000
s_var4 := upper( s_var4 )
testvar("modified main thread values")
hb_threadJoin( hb_threadStart( @thFunc() ) )
testvar("modified main thread values")
return
proc testvar( cMsg )
? cMsg
? "s_var1:", hb_valtoExp( s_var1 )
? "s_var2:", hb_valtoExp( s_var2 )
? "s_var3:", hb_valtoExp( s_var3 )
? "s_var4:", hb_valtoExp( s_var4 )
wait
?
return
proc thFunc()
testvar("initial child thread values")
aadd( s_var1, "Y" )
s_var2[ "Y" ] := "abc"
s_var3 -= 500000
s_var4 += " CHANGED"
testvar("modified child thread values")
return