ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> tcl-threads
tcl-threads
[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

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved