FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Multithreading
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Multithreading
Posted: Mon May 27, 2013 06:06 PM
Antonio,

what do you think about this sample (xHarbour):

Code (fw): Select all Collapse
FUNCTION MAIN()

    LOCAL hThr := STARTTHREAD( @MyFunc() )

    INKEY( 0 )

    STOPTHREAD( hThr )

    INKEY( 0 )

    RETURN NIL


STATIC FUNCTION MYFUNC()

    WHILE .T.
        THREADSLEEP( 1000 )
        TONE( 440, 1 )
    ENDDO

    RETURN NIL


EMG
Posts: 7318
Joined: Thu Oct 18, 2012 07:17 PM
Re: Multithreading
Posted: Mon May 27, 2013 07:06 PM

what I can do with it ?

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Multithreading
Posted: Mon May 27, 2013 07:21 PM

Enrico,

It seems what you were looking for :-)

Does it work fine ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Multithreading
Posted: Mon May 27, 2013 07:31 PM
Silvio,

Silvio.Falconi wrote:what I can do with it ?


I'm experimenting a way to make wait animations smooth even with loops without SysRefresh() inside them.

EMG
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Multithreading
Posted: Mon May 27, 2013 07:32 PM
Antonio,

Antonio Linares wrote:Enrico,

It seems what you were looking for :-)

Does it work fine ?


It seems so. :-)

EMG
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Multithreading
Posted: Mon May 27, 2013 07:45 PM

I just found that MT EXEs are slower than ST ones. :-(

Any comments?

EMG

Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Multithreading
Posted: Mon May 27, 2013 08:06 PM

Enrico,

How have you measured it ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Multithreading
Posted: Mon May 27, 2013 09:16 PM
Antonio,

Antonio Linares wrote:Enrico,

How have you measured it ?


With Seconds(). What else?

EMG
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Multithreading
Posted: Mon May 27, 2013 10:00 PM

Could you provide a small example of what you tested ? thanks :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Multithreading
Posted: Tue May 28, 2013 06:42 AM
Antonio,

Antonio Linares wrote:Could you provide a small example of what you tested ? thanks :-)


Something like this:

Code (fw): Select all Collapse
FUNCTION MAIN()

    LOCAL nSec

    LOCAL cVal

    USE MYTABLE

    nSec = SECONDS()

    WHILE !EOF()
        cVal = FIELD -> myfield
        SKIP
    ENDDO

    ? "Assign and skip", SECONDS() - nSec

    CLOSE

    INKEY( 0 )

    RETURN NIL


Here I get ST: 31 MT: 41!

EMG
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Re: Multithreading
Posted: Tue May 28, 2013 07:10 AM

Enrico,

just to understand, what could be the advantages using MT instead of ST ? What functions could be put in threads ?

Im my understanding a database application is a single thread application with single tasks, e.g. browsing a dbf or searching in a dbf. What can be done, to get simultaneous tasks ?

Stefan

kind regards

Stefan
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Multithreading
Posted: Tue May 28, 2013 07:58 AM
Stefan,

StefanHaupt wrote:Enrico,

just to understand, what could be the advantages using MT instead of ST ? What functions could be put in threads ?

Im my understanding a database application is a single thread application with single tasks, e.g. browsing a dbf or searching in a dbf. What can be done, to get simultaneous tasks ?

Stefan


Don't know. I just need something to get smooth wait animations during loops without SysRefresh() in them.

EMG
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Multithreading
Posted: Tue May 28, 2013 08:05 AM

Enrico,

Thanks for your example, what source code had you running on the second thread ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9022
Joined: Thu Oct 06, 2005 08:17 PM
Re: Multithreading
Posted: Tue May 28, 2013 08:08 AM
Antonio,

Antonio Linares wrote:Enrico,

Thanks for your example, what source code had you running on the second thread ?


Nothing. I created no threads. Just link vmmt.lib and cw32mt.lib in.

EMG
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Multithreading
Posted: Tue May 28, 2013 10:18 AM

Enrico,

How many records you have on the DBF ?

regards, saludos

Antonio Linares
www.fivetechsoft.com