M src/main.tcl => src/main.tcl +7 -7
@@ 21,11 21,11 @@ package require sqlite3
${log}::info "tclircc $version <https://amehut.dev/~aleteoryx/tclircc>"
${log}::info "running from $path"
-src threads.tcl
+src router.tcl
-proc on_threads_update {} {
- puts "threads updated!"
- t::debug
+proc on_routes_update {} {
+ puts "routes updated!"
+ r::debug
}
proc start_thread {name} {
@@ 36,7 36,7 @@ proc start_thread {name} {
${log}::debug "starting $name thread..."
set thread [thread::create -preserved]
- threads::manage $thread tclircc::$name
+ router::manage $thread tclircc::$name
thread::send $thread [list variable path $path version $version]
if {[thread::send $thread \
@@ 50,7 50,7 @@ proc start_thread {name} {
start_thread db
-thread::send [t::ns tclircc::db] {path_to_core} core_db_path
+thread::send [r::ns tclircc::db] {path_to_core} core_db_path
sqlite3 core_db $core_db_path -create true -fullmutex true
src migrate_core.tcl
@@ 62,7 62,7 @@ start_thread ui
plugins::load [file join $path .. testplugin]
${log}::debug "opening initial window..."
-t::exec tclircc::ui {
+r::exec tclircc::ui {
mk_toplevel name
expr {$name}
} {
M src/plugins.tcl => src/plugins.tcl +5 -5
@@ 258,7 258,7 @@ namespace eval plugins {
if {!$skip_prompt} {
set manifest [list $manifest]
set dir [list $dir]
- t::exec tclircc::ui {
+ r::exec tclircc::ui {
set manifest %manifest
prompt -type yesno \
-title "Plugin Installation" \
@@ 297,7 297,7 @@ namespace eval plugins {
set manifest [list $manifest]
set dir [list $dir]
- t::exec tclircc::ui {
+ r::exec tclircc::ui {
set manifest %manifest
prompt -type yesno \
-title "Plugin Tampering Detected!" \
@@ 328,7 328,7 @@ namespace eval plugins {
if {!$skip_prompt && [clock seconds] > $trusted_till} {
set manifest [list $manifest]
set dir [list $dir]
- t::exec tclircc::ui {
+ r::exec tclircc::ui {
set manifest %manifest
prompt -type yesno \
-title "Plugin Update" \
@@ 361,7 361,7 @@ namespace eval plugins {
set verstr [list "v[join $version .]"]
set manifest [list $manifest]
set dir [list $dir]
- t::exec tclircc::ui {
+ r::exec tclircc::ui {
set manifest %manifest
tk_messageBox -type yesno \
-title "Plugin Downgrade!" \
@@ 377,7 377,7 @@ namespace eval plugins {
switch -- $result {
yes {
${log}::warn "downgrading [dict get $manifest qslug]! making a backup!"
- t::exec tclircc::db backup {
+ r::exec tclircc::db backup {
::plugins::install $manifest %dir
}
}
R src/threads.tcl => src/router.tcl +31 -31
@@ 1,19 1,19 @@
#***
-# [manpage_begin threads tclircc 0.0.1]
-# [titledesc {Component threads.tcl}]
+# [manpage_begin router tclircc 0.0.1]
+# [titledesc {Component router.tcl}]
# [description]
-namespace eval threads {
- variable threads [list main [thread::id]]
- variable log [logger::init tclircc::threads]
+namespace eval router {
+ variable routes [list main [thread::id]]
+ variable log [logger::init tclircc::router]
- variable t_ns_script {
- namespace eval ::t {
+ variable r_ns_script {
+ namespace eval ::r {
variable ns
variable self
proc update {} {
variable ns
- thread::send -head [set ns(main)] threads::update
+ thread::send -head [set ns(main)] ::router::update
}
proc ns {name} {
variable ns
@@ 21,7 21,7 @@ namespace eval threads {
}
proc debug {} {
variable log
- parray t::ns
+ parray r::ns
}
proc util_regsub_prep {data} {
set first -1
@@ 69,14 69,14 @@ namespace eval threads {
variable ns
variable self
- set script [uplevel [list ::t::util_pctsub $script]]
- set followup [uplevel [list ::t::util_pctsub $followup]]
+ set script [uplevel [list ::r::util_pctsub $script]]
+ set followup [uplevel [list ::r::util_pctsub $followup]]
if [string length $followup] {
set realscript {
set result [eval %script]
set script [concat [list set result $result] ";" %followup]
- thread::send -async [t::ns %self] $script
+ thread::send -async [r::ns %self] $script
}
regsub %self $realscript [util_regsub_prep [list $self]] realscript
regsub %followup $realscript [util_regsub_prep [list $followup]] realscript
@@ 88,40 88,40 @@ namespace eval threads {
}
}
}
- eval $t_ns_script
- set ::t::self "main"
+ eval $r_ns_script
+ set ::r::self "main"
proc manage {tid name} {
- variable threads
+ variable routes
variable log
- variable t_ns_script
- dict set threads $name $tid
+ variable r_ns_script
+ dict set routes $name $tid
${log}::debug "managing thread $tid as \"$name\""
- thread::send -head $tid [concat $t_ns_script ";" [list set ::t::self $name]]
+ thread::send -head $tid [concat $r_ns_script ";" [list set ::r::self $name]]
- ::threads::update
+ ::router::update
}
proc unmanage {name} {
- variable threads
+ variable routes
variable log
- dict unset threads $name
+ dict unset routes $name
${log}::debug "unmanaging thread $tid (\"$name\")"
- ::threads::update
+ ::router::update
}
proc update {} {
- variable threads
- dict for {name tid} $threads {
- if ![thread::exists $tid] {dict unset $threads $name}
+ variable routes
+ dict for {name tid} $routes {
+ if ![thread::exists $tid] {dict unset routes $name}
}
- dict for {name tid} $threads {
- set payload {array unset t::ns; }
- dict for {n t} $threads {
- append payload {set t::ns(} $n {) } $t {; }
+ dict for {name tid} $routes {
+ set payload {array unset r::ns; }
+ dict for {n t} $routes {
+ append payload [list array set r::ns [list $n $t]] ";\n"
}
append payload {
- if {"on_threads_update" in [info procs on_threads_update]} \
- on_threads_update
+ if {"on_routes_update" in [info procs on_routes_update]} \
+ on_routes_update
}
thread::send -head $tid $payload
}