Files
harbour-core/harbour/tests/mt/mttest10.prg
Przemyslaw Czerpak 520a0a0206 2008-10-22 05:03 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbstack.h
  * harbour/include/hbgtcore.h
  * harbour/include/hbthread.h
  * harbour/include/hbapigt.h
  * harbour/source/vm/estack.c
  * harbour/source/vm/hvm.c
  * harbour/source/vm/thread.c
  * harbour/source/rtl/hbgtcore.c
    + added support for optional allocating independent console window by
      each thread. By default new thread inherits console Window from
      parent thread. But each thread can allocate its own console window
      by calling hb_gtReload( <cGtName> ) function, f.e. by:
         hb_gtReload( hb_gtVersion() )
      If GT driver supports such functionality then new it will allocate
      new console windows.
      Each console window has reference counter which is increased when
      new thread starts and decreased when hb_gtReload() is executed or
      thread terminates. When counter reach zero give console window is
      destroyed.

  * harbour/source/rtl/gtwvt/gtwvt.c
    ! use SendNotifyMessage() instead of SendMessage() to not block
      threads which inherited GT from parent thread. Why non of MS-Win
      users reported this problem?
    + added reference counter to window class for multi GT support

  + harbour/tests/mt/mttest10.prg
    + added demonstration/test code for using independent console window
      in different threads. It needs GT driver which supports such
      functionality, f.e GTXWC in *nixes or GTWVT in MS-Windows

  * harbour/tests/mt/mttest09.prg
    ! fixed typo in comment
2008-10-22 03:03:58 +00:00

56 lines
1.1 KiB
Plaintext

/*
* $Id$
*/
/*
* Harbour Project source code:
* demonstration/test code for using independent console window in
* different thread. It needs GT driver which supports such functionality.
*
* Copyright 2008 Przemyslaw Czerpak <druzus / at / priv.onet.pl>
* www - http://www.harbour-project.org
*
*/
#include "inkey.ch"
#ifdef __PLATFORM__WINDOWS
REQUEST HB_GT_WVT_DEFAULT
#define THREAD_GT hb_gtVersion()
#else
REQUEST HB_GT_STD_DEFAULT
#define THREAD_GT "XWC"
#endif
proc main()
local i, aThreads
if !hb_mtvm()
? "This program needs HVM with MT support"
quit
endif
? "Starting threads..."
aThreads := {}
for i := 1 to 3
aadd( aThreads, hb_threadStart( @thFunc() ) )
? i, "=>", atail( aThreads )
next
? "Waiting for threads"
while inkey() != K_ESC
if hb_threadWait( aThreads, 0.1, .t. ) == len( aThreads )
wait
exit
endif
?? "."
enddo
return
proc thFunc()
/* allocate own GT driver */
hb_gtReload( THREAD_GT )
use test shared
browse()
return