~aleteoryx/tclircc

ref: dd09632658fec09c6e07d172295b0b1abc269b4a tclircc/main.tcl -rwxr-xr-x 1.4 KiB
dd096326aleteoryx this component is just gonna be routing management actually a month ago
                                                                                
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
#!/bin/env tclsh

set path [file dirname [dict get [info frame 0] file]]
set version v0.0.1

package require Thread
package require logger
set log [logger::init tclircc::main]

${log}::info "tclircc $version <https://amehut.dev/~aleteoryx/tclircc>"
${log}::info "running from $path"

source threads.tcl

${log}::debug "starting db thread..."
set db_thread [thread::create -preserved]
threads::manage $db_thread tclircc::db
thread::send $db_thread [list variable path $path version $version]
if {[thread::send $db_thread [list source "$path[file separator]db[file separator]main.tcl"] result] == 1} {
  ${log}::critical "couldn't start db thread: $result"
  exit -1
}
${log}::debug "started db thread."

${log}::debug "starting ui thread..."
set ui_thread [thread::create -preserved]
threads::manage $ui_thread tclircc::ui
thread::send $ui_thread [list variable path $path version $version]
if {[thread::send $ui_thread [list source "$path[file separator]ui[file separator]main.tcl"] result] == 1} {
  ${log}::critical "couldn't start ui thread: $result"
  exit -1
}
${log}::debug "started ui thread."

update
foreach key [array names threads::ns] {
  ${log}::debug "thread \"$key\" has id [set threads::ns($key)]"
}

${log}::debug "opening main window..."
thread::send $ui_thread {mk_toplevel name; return $name} mainwin
${log}::debug "main window opened: $mainwin"

${log}::info "entering event loop"
vwait nil