This commit contains a number of related mailbox issues: - Add extra parameters to mailbox_respond_receive to allow both the number of bytes/handles passed in, and the size of the byte/handle buffers to be passed in. - Don't delete mailbox messages on receipt if the caller is waiting on reply - Correctly pass status messages along with a mailbox::replyer object - Actually wake the calling thread in the mailbox::replyer dtor - Make sure to release locks _before_ calling thread::wake() on blocked threads, as that may cause them to be scheduled ahead of the current thread.
66 lines
2.0 KiB
Modula-2
66 lines
2.0 KiB
Modula-2
# Mailboxes are objects that enable synchronous or asynchronous
|
|
# IPC via short message-passing of bytes and handles.
|
|
|
|
object mailbox : object {
|
|
uid 99934ad04ece1e07
|
|
|
|
capabilities [
|
|
send
|
|
receive
|
|
close
|
|
]
|
|
|
|
method create [constructor]
|
|
method close [destructor cap:close]
|
|
|
|
# Asynchronously send a message to the reciever
|
|
method send [cap:send handle] {
|
|
param tag uint64
|
|
param data buffer [zero_ok]
|
|
param handles ref object [list]
|
|
}
|
|
|
|
# Receive a pending message, or block waiting for a message to
|
|
# arrive if block is true.
|
|
method receive [cap:receive] {
|
|
param tag uint64 [out]
|
|
param data buffer [out zero_ok]
|
|
param handles ref object [out list zero_ok]
|
|
param reply_tag uint16 [out optional]
|
|
param badge uint64 [out optional]
|
|
param flags uint64
|
|
}
|
|
|
|
# Send a message to the reciever, and block until a
|
|
# response is sent. Note that getting this response
|
|
# does not require the receive capability.
|
|
method call [cap:send handle] {
|
|
param tag uint64 [inout]
|
|
param data buffer [inout zero_ok]
|
|
param handles ref object [inout list zero_ok]
|
|
}
|
|
|
|
# Respond to a message sent using call. Note that this
|
|
# requires the receive capability and not the send capability.
|
|
method respond [cap:receive] {
|
|
param tag uint64
|
|
param data buffer [zero_ok]
|
|
param handles ref object [list zero_ok]
|
|
param reply_tag uint16
|
|
}
|
|
|
|
# Respond to a message sent using call, and wait for another
|
|
# message to arrive. Note that this does not require the send
|
|
# capability.
|
|
method respond_receive [cap:receive] {
|
|
param tag uint64 [inout]
|
|
param data buffer [inout zero_ok]
|
|
param data_in size
|
|
param handles ref object [inout list zero_ok]
|
|
param handles_in size
|
|
param reply_tag uint16 [inout]
|
|
param badge uint64 [out optional]
|
|
param flags uint64
|
|
}
|
|
}
|