mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-03 17:56:21 +03:00
Ensure that initialization of Tcl interpretor is performed in the same thread where commands are evaluated. Added test demo draw bug30430
47 lines
960 B
Plaintext
47 lines
960 B
Plaintext
# testgrid demo draw -overwrite
|
|
|
|
catch {cpulimit 10}
|
|
|
|
package require Thread
|
|
|
|
set NBTHREADS 1
|
|
set NBWORKERS 1
|
|
|
|
puts "Creating worker"
|
|
set worker [tpool::create -minworkers $NBWORKERS -maxworkers $NBWORKERS]
|
|
|
|
puts "Suspending worker"
|
|
tpool::suspend $worker
|
|
|
|
puts "Arranging jobs"
|
|
for {set i 1} {$i <= $NBTHREADS} {incr i} {
|
|
set job [tpool::post $worker "puts Executing_job_$i"]
|
|
puts "Job $i: $job"
|
|
# set job [tpool::post -nowait $worker "puts $i"]
|
|
set jobs($job) $job
|
|
}
|
|
|
|
puts "Resuming worker"
|
|
tpool::resume $worker
|
|
|
|
puts "Waiting while all threads complete"
|
|
after 1000
|
|
|
|
puts "Obtaining results"
|
|
while { [llength [array names jobs]] > 0 } {
|
|
puts "Queue: [array names jobs]"
|
|
|
|
foreach job [tpool::wait $worker [array names jobs]] {
|
|
puts -nonewline "Completed $job: "
|
|
puts "[tpool::get $worker $job]"
|
|
unset jobs($job)
|
|
}
|
|
}
|
|
|
|
puts "Releasing worker"
|
|
tpool::release $worker
|
|
|
|
catch {cpulimit 0}
|
|
|
|
puts "TEST COMPLETED"
|