diff options
author | Determinant <tederminant@gmail.com> | 2019-06-07 16:00:27 -0400 |
---|---|---|
committer | Determinant <tederminant@gmail.com> | 2019-06-07 16:00:27 -0400 |
commit | 316b61a15ff334a27462715ed4c99cf244a25701 (patch) | |
tree | d97616afca2171e335f99b8d222634f62eabfd64 /salticidae.go | |
parent | f32e3109526f2d4e980c03dd65f7c94edff4d2b2 (diff) |
use SigEvent callback in the example
Diffstat (limited to 'salticidae.go')
-rw-r--r-- | salticidae.go | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/salticidae.go b/salticidae.go index 4a8712a..1dce21e 100644 --- a/salticidae.go +++ b/salticidae.go @@ -4,8 +4,10 @@ package salticidae // #cgo CFLAGS: -I${SRCDIR}/salticidae/include/ // #cgo LDFLAGS: ${SRCDIR}/salticidae/libsalticidae.so -Wl,-rpath=${SRCDIR}/salticidae/ // #include <stdlib.h> +// #include <signal.h> // #include "salticidae/netaddr.h" // #include "salticidae/network.h" +// #include "salticidae/event.h" import "C" import "unsafe" @@ -26,6 +28,7 @@ type EventContext = *C.struct_eventcontext_t func NewEventContext() EventContext { return C.eventcontext_new() } func (self EventContext) Dispatch() { C.eventcontext_dispatch(self) } +func (self EventContext) Stop() { C.eventcontext_stop(self) } type MsgNetworkConfig = *C.struct_msgnetwork_config_t @@ -38,3 +41,16 @@ func NewMsgNetwork(ec EventContext, config MsgNetworkConfig) MsgNetwork { func (self MsgNetwork) Start() { C.msgnetwork_start(self) } func (self MsgNetwork) Listen(addr NetAddr) { C.msgnetwork_listen(self, addr) } func (self MsgNetwork) Connect(addr NetAddr) { C.msgnetwork_connect(self, addr) } +func (self MsgNetwork) Free() { C.msgnetwork_free(self) } + +type SigEvent = *C.sigev_t +type SigEventCallback = C.sigev_callback_t +var SIGTERM = C.SIGTERM +var SIGINT = C.SIGINT + +func NewSigEvent(ec EventContext, cb SigEventCallback) SigEvent { + return C.sigev_new(ec, cb) +} + +func (self SigEvent) Add(sig int) { C.sigev_add(self, C.int(sig)) } +func (self SigEvent) Free() { C.sigev_free(self) } |