attempt for jswota in js

This commit is contained in:
2025-06-08 00:49:19 -05:00
parent 34dcd0a235
commit 3176e6775d
15 changed files with 839 additions and 241 deletions

View File

@@ -66,7 +66,7 @@ function noop() {}
globalThis.log = new Proxy(logs, {
get(target,prop,receiver) {
if (target[prop])
return (...args) => args.forEach(arg => target[prop](arg))
return (...args) => target[prop](args.join(' '))
return noop
}
@@ -254,7 +254,8 @@ var default_config = {
ar_timer: 60,
actor_memory:0,
net_service:0.1,
reply_timeout:60
reply_timeout:60,
main: false,
}
config.system ??= {}
@@ -275,11 +276,8 @@ function load_actor_config(program) {
}
if (config.actors && config.actors[actor_name]) {
// Merge actor config into cell.args
for (var key in config.actors[actor_name]) {
log.console(`setting ${key}`)
for (var key in config.actors[actor_name])
cell.args[key] = config.actors[actor_name][key]
}
}
}
@@ -557,6 +555,8 @@ function actor_send_immediate(actor, send) {
}
}
var jswota = use('jswota')
function actor_send(actor, message) {
if (actor[HEADER] && !actor[HEADER].replycc) // attempting to respond to a message but sender is not expecting; silently drop
return
@@ -573,7 +573,14 @@ function actor_send(actor, message) {
// message to actor in same flock
if (actor[ACTORDATA].id && actor_mod.mailbox_exist(actor[ACTORDATA].id)) {
actor_mod.mailbox_push(actor[ACTORDATA].id, message)
var st = time.number()
var m1 = jswota.encode(message)
var m1t = time.number()-st
st = time.number()
var m2 = wota.encode(message)
var m2t = time.number()-st
log.console(`jswota: ${m1.length} bits in ${m1t}. wota: ${m2.length} bits in ${m2t}.`)
actor_mod.mailbox_push(actor[ACTORDATA].id, m2)
return
}