Tcl Source Code

Artifact [c97ec5cfc3]
Login

Artifact c97ec5cfc39183720ecc34f95fd9cc97bd0d6d1f:

Attachment "threadpool_leakdemo84.tcl" to ticket [3382401fff] added by auriocus 2011-07-30 03:05:44.
# version that leaks
package require Thread
set t [tpool::create]

proc leak {} {
	# compute 1000 rand() s in parallel
	set joblist {}
	for {set i 0} {$i<1000} {incr i} {
		lappend joblist [tpool::post -nowait $::t {expr rand()}]
	}
	
	set max 0.0
	while {[llength $joblist]!=0} {
		foreach job [tpool::wait $::t $joblist joblist] {
			set max [tpool::get $::t $job]
		}
	}
	puts "Max is $max"

}

time leak 10000