Multithreading

Multithreading

Postby Enrico Maria Giordano » Mon May 27, 2013 6:06 pm

Antonio,

what do you think about this sample (xHarbour):

Code: Select all  Expand view
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
User avatar
Enrico Maria Giordano
 
Posts: 8330
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Multithreading

Postby Silvio.Falconi » Mon May 27, 2013 7:06 pm

what I can do with it ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 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
User avatar
Silvio.Falconi
 
Posts: 6796
Joined: Thu Oct 18, 2012 7:17 pm

Re: Multithreading

Postby Antonio Linares » Mon May 27, 2013 7:21 pm

Enrico,

It seems what you were looking for :-)

Does it work fine ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41322
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Multithreading

Postby Enrico Maria Giordano » Mon May 27, 2013 7: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
User avatar
Enrico Maria Giordano
 
Posts: 8330
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Multithreading

Postby Enrico Maria Giordano » Mon May 27, 2013 7:32 pm

Antonio,

Antonio Linares wrote:Enrico,

It seems what you were looking for :-)

Does it work fine ?


It seems so. :-)

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8330
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Multithreading

Postby Enrico Maria Giordano » Mon May 27, 2013 7:45 pm

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

Any comments?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8330
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Multithreading

Postby Antonio Linares » Mon May 27, 2013 8:06 pm

Enrico,

How have you measured it ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41322
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Multithreading

Postby Enrico Maria Giordano » Mon May 27, 2013 9:16 pm

Antonio,

Antonio Linares wrote:Enrico,

How have you measured it ?


With Seconds(). What else?

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8330
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Multithreading

Postby Antonio Linares » 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
User avatar
Antonio Linares
Site Admin
 
Posts: 41322
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Multithreading

Postby Enrico Maria Giordano » Tue May 28, 2013 6:42 am

Antonio,

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


Something like this:

Code: Select all  Expand view
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
User avatar
Enrico Maria Giordano
 
Posts: 8330
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Multithreading

Postby StefanHaupt » Tue May 28, 2013 7: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
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: Multithreading

Postby Enrico Maria Giordano » Tue May 28, 2013 7: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
User avatar
Enrico Maria Giordano
 
Posts: 8330
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Multithreading

Postby Antonio Linares » Tue May 28, 2013 8:05 am

Enrico,

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

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41322
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Multithreading

Postby Enrico Maria Giordano » Tue May 28, 2013 8: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
User avatar
Enrico Maria Giordano
 
Posts: 8330
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Multithreading

Postby Antonio Linares » Tue May 28, 2013 10:18 am

Enrico,

How many records you have on the DBF ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41322
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 12 guests