Add 'external' and switch functions.
This commit is contained in:
parent
8cc19999f5
commit
243dff0e55
@ -1,5 +1,5 @@
|
||||
name: ipc
|
||||
version: 0.1.2
|
||||
version: 0.2.0
|
||||
|
||||
authors:
|
||||
- Philippe Pittoli <karchnu@karchnu.fr>
|
||||
@ -15,6 +15,6 @@ dependencies:
|
||||
branch: master
|
||||
|
||||
libraries:
|
||||
libipc: ">= 0.1.2"
|
||||
libipc: ">= 0.2.0"
|
||||
|
||||
license: ISC
|
||||
|
@ -34,4 +34,18 @@ lib LibIPC
|
||||
fun close = ipc_close(Void*, LibC::UInt64T) : LibC::Int
|
||||
fun close_fd = ipc_close_fd(Void*, LibC::Int) : LibC::Int
|
||||
fun close_all = ipc_close_all(Void*) : LibC::Int
|
||||
|
||||
# Add a new external file descriptor.
|
||||
# LibIPC won't automatically read the content.
|
||||
fun external = ipc_add_external (Void*, LibC::Int) : LibC::Int
|
||||
|
||||
# Add a new switch (messages are automatically exchanged between these two file descriptors).
|
||||
fun add_switch = ipc_add_switch (Void*, LibC::Int, LibC::Int) : LibC::Int
|
||||
|
||||
# Set IO callbacks for a file descriptor.
|
||||
# Returned "char" is a cb_event_types enum.
|
||||
# One of the callbacks can be "NULL" to keep the default callback, thus changing only input or output operations.
|
||||
fun switch_callbacks = ipc_set_switch_callbacks (Void*, LibC::Int,
|
||||
(LibC::Int, LibC::Char*, LibC::UInt64T* -> LibC::Char),
|
||||
(LibC::Int, LibC::Char*, LibC::UInt64T -> LibC::Char));
|
||||
end
|
||||
|
@ -108,6 +108,26 @@ class IPC
|
||||
end
|
||||
end
|
||||
|
||||
def external(fd : LibC::Int)
|
||||
if LibIPC.external(@context, fd) != 0
|
||||
raise "Oh noes, 'external' iz brkn"
|
||||
end
|
||||
end
|
||||
|
||||
def add_switch(fd1 : LibC::Int, fd2 : LibC::Int)
|
||||
if LibIPC.add_switch(@context, fd1, fd2) != 0
|
||||
raise "Oh noes, 'add_switch' iz brkn"
|
||||
end
|
||||
end
|
||||
|
||||
def switch_callbacks(fd : LibC::Int,
|
||||
fn_in : (LibC::Int, LibC::Char*, LibC::UInt64T* -> LibC::Char),
|
||||
fn_out : (LibC::Int, LibC::Char*, LibC::UInt64T -> LibC::Char))
|
||||
if LibIPC.switch_callbacks(@context, fd, fn_in, fn_out) != 0
|
||||
raise "Oh noes, 'switch_callbacks' iz brkn"
|
||||
end
|
||||
end
|
||||
|
||||
def wait : IPC::Event
|
||||
eventtype : UInt8 = 0
|
||||
index : LibC::UInt64T = 0
|
||||
|
Loading…
Reference in New Issue
Block a user