ludic.net: a message's record, bytes and lists kept - queued ones back to a pool once sent or taken, the inbox's two drains on, a read text interned
np_queue made a NetMsg and a buffer per message, every flush a new keep list, and every message that came in a NetMessage and a buffer; nr_text a new string per text read. A party plays at dozens a second, so all of it is kept now: a pool of MTU-sized records for the queue (a peer's two lists swapped by the flush), the inbox's records in two halves swapped when a message finds the inbox empty, net_written's one record, a relay hello's and a STUN request's bytes in one scratch buffer, and the texts read out interned. Tests: 6000 messages with the heap flat (Os.heap_bytes), and an inbox record that holds still across a drain and comes back two drains on. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
e6729b3123
commit
ca69a3f9ae
11 changed files with 134 additions and 20 deletions
|
|
@ -77,15 +77,14 @@ function net__messages(net_st: mut NetState, slot: int, n: int) -> void {
|
|||
}
|
||||
|
||||
# onto the inbox - except a heartbeat, and on a host anything but a hello before its welcome
|
||||
function net__deliver(net_st: NetState, slot: int, from: int, kind: int, o: int, ml: int) -> void {
|
||||
function net__deliver(net_st: mut NetState, slot: int, from: int, kind: int, o: int, ml: int) -> void {
|
||||
if kind == NET_BEAT { return }
|
||||
if net_st.net__state == NET_HOSTING and net_st.net__peers[slot].pid < 2 and kind != NET_HELLO { return }
|
||||
let m = new NetMessage
|
||||
let m = net__in_take(net_st)
|
||||
m.slot = slot
|
||||
m.from = from
|
||||
m.kind = kind
|
||||
m.len = ml
|
||||
m.data = buffer(ml)
|
||||
nb_copy(m.data, 0, net_st.net__in, o, ml)
|
||||
q_push(net_inbox(net_st), m)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue