RE: [Tcl-Threads] does tpool::post really work in blocking mode?
by Jeff Hobbs other posts by this author
Nov 7 2005 2:00PM messages near this date
[Tcl-Threads] does tpool::post really work in blocking mode?
|
[Tcl-Threads] boost::threads and tcl/tk
What platform and version was that using? Using ActiveTcl 8.4.11.2
and 8.5.0.0b4 on Windows XP, I got:
C:\temp> tclsh84 foo.tcl
1
tid00000C3C tid00000BEC
2
tid00000C3C tid00000BEC
C:\temp> tclsh85 foo.tcl
1
tid00000CAC tid000008E0
2
tid00000CAC tid000008E0
Jeff Hobbs, The Tcl Guy
http://www.ActiveState.com/, a division of Sophos
-----Original Message-----
From: tcl-threads-admin@[...].net
[mailto:tcl-threads-admin@[...].net] On Behalf Of Roster Wang
Sent: November 6, 2005 7:17 PM
To: tcl-threads@[...].net
Subject: [Tcl-Threads] does tpool::post really work in blocking mode?
package require Thread
set script {
thread::send %s [list set flag 1]
}
set script [format $script [thread::id]]
set pid [tpool::create -maxworkers 1]
set flag 0
while { !$flag } {
puts [tpool::post $pid $script]
puts [thread::names]
}
tpool::release $pid
since only one worker is allowed in this case, there will be only two jobs
generated by tpool.
at the every beginning, the worker picks the first job and expect to set the
flag in main thread.
Meanwhile, the main thread waits in event loop until the woker set the flag
successfully and takes the second job from the pool.
Then the main thread won't post anymore job because flag is set.
However, I got confused by receiving the following result:
1
tid00000548
2
tid00000548
3
tid00000548
4
tid00000548
5
tid00000548
6
tid00000510 tid00000548
7
tid00000510 tid00000548
can anyone explain this? thanks a lot
-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Tcl-Threads mailing list
Tcl-Threads@[...].net
https://lists.sourceforge.net/lists/listinfo/tcl-threads
Thread:
Roster Wang
Jeff Hobbs
|