~aleteoryx/ntalk

95385297482e8c1dfa3f5556905e3bfb8aee60bd — Aleteoryx 2 months ago 52c924d
move sendmsg to network thread
1 files changed, 10 insertions(+), 10 deletions(-)

M ntalk.tcl
M ntalk.tcl => ntalk.tcl +10 -10
@@ 688,7 688,7 @@ proc setlastmsg {new} {
}

set lastmsg 0
set netcode {
set netcode { ### ENTER SECTION THAT MAY BE THREADED ###
set lastmsg 0

proc sendl {line} {


@@ 732,6 732,13 @@ proc send {line} {
	return 0
}

proc sendmsg {msg} {
	if {[send $msg]} {
		bufpush "$msg"
		bufdown
	}
}

proc poll {} {
	global lastmsg
	sendl "POLL $lastmsg"


@@ 784,7 791,7 @@ proc doskip {delay} {
	}
	set pmid [after $delay doskip $delay]
}
}
}; ### END OF SECTION THAT MAY BE THREADED ###

if {[catch {package require Thread}] == 0} { # threading supported!
	set threads 1


@@ 814,6 821,7 @@ if {[catch {package require Thread}] == 0} { # threading supported!

	interp alias {} hist {} thread::send -async $nett hist
	proc send {line} [subst -nocommands { thread::send $nett [list send [set line]] }]
	proc sendmsg {line} [subst -nocommands { thread::send -async $nett [list sendmsg [set line]] }]
	proc pollmsgs {n} [subst -nocommands { thread::send -async $nett [list pollmsgs [set n]] }]
	proc last {n} [subst -nocommands { thread::send -async $nett [list last [set n]] }]
} else {


@@ 870,14 878,6 @@ proc bufclear {} {
	if !$threads update
}

proc sendmsg {msg} {
	global lastmsg
	if {[send $msg]} {
		bufpush "$msg"
		bufdown
	}
}

proc n64k_secs {msgcount} {
	# 2025-09-19 01:59:38 GMT
	set proto_epoch 1758247178