[Tcl-Threads] does tpool::post really work in blocking mode?
by Roster Wang other posts by this author
Nov 6 2005 7:17PM messages near this date
[Tcl-Threads] Call For Papers: 13th Annual Tcl/Tk Conference, Oct. 9-13, 2006
|
RE: [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
Attachments:
unknown1
unknown2
Thread:
Roster Wang
Jeff Hobbs
|