Tcl Source Code

Artifact [19acaf68f9]
Login

Artifact 19acaf68f986d74ac56c427a67155272d3d1ea94:

Attachment "tpoolBug.tcl" to ticket [3534440fff] added by tomkiti 2012-06-12 04:05:56.
# Create a thread pool and 2 jobs.
package require Thread
set tpool [tpool::create]
set job1 [tpool::post $tpool {after 1000}]
set job2 [tpool::post $tpool {after 2000}]

# Wait for the first job to complete.
set completed [tpool::wait $tpool [list $job1 $job2] pending]
puts "Completed = $completed"

# BUG: Pending list is empty, should be "2".
puts "Pending = $pending"

# Wait for the second job to complete.
tpool::wait $tpool $job2
tpool::release $tpool

# Wait for pool to terminate (?), otherwise receive error:
# "called Tcl_FindHashEntry on deleted table".
after 1 {set forever 1}
vwait forever


# Output:
#
# Completed = 1
# Pending =