mirror of
https://github.com/justinian/jsix.git
synced 2025-12-09 16:04:32 -08:00
[kernel] Replace endpoint with new mailbox API
The new mailbox kernel object API offers asynchronous message-based IPC for sending data and handles between threads, as opposed to endpoint's synchronous model.
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
# Channels are objects that enable synchronous IPC of
|
||||
# arbitrary-sized messages.
|
||||
|
||||
object endpoint : object {
|
||||
uid c5882f24a4c03b7e
|
||||
|
||||
capabilities [
|
||||
send
|
||||
receive
|
||||
]
|
||||
|
||||
method create [constructor]
|
||||
|
||||
# Send a message on a channel. Blocks until the message
|
||||
# is received.
|
||||
method send [cap:send] {
|
||||
param tag uint64
|
||||
param data buffer
|
||||
}
|
||||
|
||||
# Receieve a message on a channel. Blocks until a message
|
||||
# is available.
|
||||
method receive [cap:receive] {
|
||||
param tag uint64 [out]
|
||||
param data buffer [out zero_ok]
|
||||
param timeout uint64 # Receive timeout in nanoseconds
|
||||
}
|
||||
|
||||
# Send a message on a channel and then await a new message.
|
||||
# Equivalent to calling send and then recieve, as a single
|
||||
# operation.
|
||||
method sendrecv [cap:send cap:receive] {
|
||||
param tag uint64 [inout]
|
||||
param data buffer [inout zero_ok]
|
||||
param timeout uint64 # Receive timeout in nanoseconds
|
||||
}
|
||||
}
|
||||
@@ -1,32 +1,63 @@
|
||||
# Mailboxes are objects that enable asynchronous IPC via event notification.
|
||||
# Mailboxes are objects that enable synchronous or asynchronous
|
||||
# IPC via short message-passing of bytes and handles.
|
||||
|
||||
object mailbox {
|
||||
object mailbox : object {
|
||||
uid 99934ad04ece1e07
|
||||
|
||||
# Create an unbound mailbox
|
||||
capabilities [
|
||||
send
|
||||
receive
|
||||
close
|
||||
]
|
||||
|
||||
method create [constructor]
|
||||
method close [destructor cap:close]
|
||||
|
||||
method close [destructor]
|
||||
|
||||
method bind {
|
||||
param index uint
|
||||
param source ref object
|
||||
param event uint
|
||||
# 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]
|
||||
}
|
||||
|
||||
method unbind {
|
||||
param index uint
|
||||
# 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
|
||||
}
|
||||
|
||||
method notify {
|
||||
param index uint
|
||||
# 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]
|
||||
}
|
||||
|
||||
method wait {
|
||||
param bitmap uint64 [out]
|
||||
# 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
|
||||
}
|
||||
|
||||
method ack {
|
||||
param bitmap uint64
|
||||
# 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 handles ref object [inout list zero_ok]
|
||||
param reply_tag uint16 [inout]
|
||||
param badge uint64 [out]
|
||||
param flags uint64
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import "objects/object.def"
|
||||
|
||||
import "objects/channel.def"
|
||||
import "objects/endpoint.def"
|
||||
import "objects/event.def"
|
||||
import "objects/mailbox.def"
|
||||
import "objects/process.def"
|
||||
import "objects/system.def"
|
||||
import "objects/thread.def"
|
||||
@@ -16,8 +16,8 @@ interface syscalls [syscall] {
|
||||
expose ref event
|
||||
expose ref process
|
||||
expose ref thread
|
||||
expose ref mailbox
|
||||
expose ref channel
|
||||
expose ref endpoint
|
||||
expose ref vma
|
||||
|
||||
# Simple no-op syscall for testing
|
||||
|
||||
Reference in New Issue
Block a user