example usage and documentation of `mailbox` module
provide an example and documentation of the mailbox module (lib/mailbox.lua).
I think we can adapt echod example to use it
actually, I think it's a good opportunity to apply mailbox to systrack example and change luaprobe to .sleep = false, splitting systrack in two separate runtimes (one for the probes and another to the chardev).. perhaps this could fix its termination.. (it's hanging.. by bet is a deadlock between driver and probe)..
@glk0 btw, are you still interested to tackle this? https://github.com/luainkernel/lunatik/issues/96#issuecomment-1993009894 If so, I can help you on using mailbox to implement this separation..
basically, we would need to move the driver code to something like systrack/driver.lua and the probes to systrack/probe.lua, than we should create a mailbox and return its queue in a function returned by probe.lua, e.g.,
-- probe.lua
...
local mbox = mailbox.outbox(size)
local function attacher()
return mbox.queue
end
return mbox
then, we can create a runtime for probes in the driver and resume it to receive its mailbox, e.g.,
-- driver.lua
...
local probe = lunatik.runtime("systrack/probe", false)
local mbox = mailbox.inbox(probe:resume())
then, we can poll the mbox in the driver.. similarly to https://github.com/ring0networks/dome/blob/master/daemon.lua#L41
@glk0 btw, are you still interested to tackle this? https://github.com/luainkernel/lunatik/issues/96#issuecomment-1993009894 If so, I can help you on using
mailboxto implement this separation..
Yeah. I'll get back to you in a few days about it.