TABLE OF CONTENTS


::pwtk::tpool::wait

SYNOPSIS

    method wait {args} {

USAGE

   $obj wait ?jobID? ?jobID ...?

DESCRIPTION

If the method is called without any arguments, then it waits for all jobs submitted to the thread-pool to finish. Otherwise, it waits only for the specified jobs to finish.

This command is blocking.

SOURCE

        set jl {}
        if { $args eq {} } {            
            set jl $jobList
        } else {
            foreach id $args {
                if { $id in $jobList } {
                    lappend jl $id
                } else {
                    ::pwtk::warning "job ID $id is not among active jobs; ignoring"
                }
            }
        }
        if { $jl eq "" } { return }

        # t.k.
        after $::pwtk::time_interval_ms
        # t.k.end
        
        set s [expr {[llength $jl] > 1 ? "s" : ""}]
        ::pwtk::print "\nWaiting for [self] job$s [join $jl {, }] to complete ...\n"
        
        while 1 {
            tpool::wait $tpid $jl running
        
            if { $running eq {} } {
                break
            } else {
                after $::pwtk::time_interval_ms
            }
        }
    }