/usr/share/tcltk/tcllib1.18/tool/pipeline.tcl is in tcllib 1.18-dfsg-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | ::namespace eval ::tool::signal {}
proc ::tool::coroutine_register {objname coroutine} {
variable all_coroutines
variable object_coroutines
variable coroutine_object
# Wake a sleeping main loop
set ::tool::wake_up 2
if {$coroutine in $all_coroutines} {
return 1
}
lappend all_coroutines $coroutine
lappend object_coroutines($objname) $coroutine
set coroutine_object($coroutine) $objname
return 0
}
proc ::tool::coroutine_unregister {coroutine} {
variable all_coroutines
variable object_coroutines
variable coroutine_object
ldelete all_coroutines $coroutine
if {[info exists coroutine_object($coroutine)]} {
set objname $coroutine_object($coroutine)
ldelete object_coroutines($objname) $coroutine
unset coroutine_object($coroutine)
}
}
proc ::tool::do_events {} {
# Process coroutines
variable all_coroutines
variable coroutine_object
set count 0
foreach coro $all_coroutines {
if {[info command $coro] eq {}} {
#puts "$coro quit"
coroutine_unregister $coro
continue
}
#puts [list RUN $coro]
try $coro on return {} {
# Terminate the coroutine
coroutine_unregister $coro
} on break {} {
# Terminate the coroutine
coroutine_unregister $coro
} on error {errtxt errdat} {
# Coroutine encountered an error
coroutine_unregister $coro
puts "ERROR $coro"
set errorinfo $::errorInfo
catch {
puts "OBJECT: $coroutine_object($coro)"
puts "CLASS: [info object class $coroutine_object($coro)]"
}
puts "$errtxt"
puts ***
puts $errorinfo
} on continue {result opts} {
# Ignore continue
if { $result eq "done" } {
incr count
coroutine_unregister $coro
}
} on ok {result opts} {
if { $result eq "done" } {
coroutine_unregister $coro
} else {
incr count
}
}
}
return $count
}
proc ::tool::main {} {
package require cron 1.2
###
# Have the cron::wake procedure wake up an idle loop instead
# of it's normal run commands in the background
###
proc ::cron::wake {} {
set ::tool::wake_up 1
}
set ::forever 1
while {$::forever} {
incr ::tool::loops(all)
if {[info command ::CRON] eq {}} {
coroutine ::CRON ::cron::runTasksCoro
}
set cron_delay [::CRON]
set tool_running [::tool::do_events]
if {$cron_delay==0 || $tool_running>0} {
incr ::tool::loops(active)
update
} else {
incr ::tool::loops(idle)
set ::tool::wake_up 0
after [expr {$cron_delay*1000}] {set ::tool::wake_up 1}
vwait ::tool::wake_up
}
}
}
proc ::tool::object_create objname {
foreach varname {
object_info
object_signal
object_subscribe
object_coroutine
} {
variable $varname
set ${varname}($objname) {}
}
set object_info($objname) [list class [info object class $objname]]
}
proc ::tool::object_rename {object newname} {
foreach varname {
object_info
object_signal
object_subscribe
object_coroutine
} {
variable $varname
if {[info exists ${varname}($object)]} {
set ${varname}($newname) [set ${varname}($object)]
unset ${varname}($object)
}
}
variable coroutine_object
foreach {coro coro_objname} [array get coroutine_object] {
if { $object eq $coro_objname } {
set coroutine_object($coro) $newname
}
}
rename $object ::[string trimleft $newname]
::tool::event::generate $object object_rename [list newname $newname]
}
proc ::tool::object_destroy objname {
::tool::event::generate $objname object_destroy [list objname $objname]
variable coroutine_object
foreach {coro coro_objname} [array get coroutine_object] {
if { $objname eq $coro_objname } {
coroutine_unregister $coro
}
}
foreach varname {
object_info
object_signal
object_subscribe
object_coroutine
} {
variable $varname
unset -nocomplain ${varname}($objname)
}
}
namespace eval ::tool {
variable trace 0
variable all_coroutines
if {![info exists all_coroutines]} {
set all_coroutines {}
}
}
package provide tool::pipeline 0.1
|