aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--event.go28
-rw-r--r--netaddr.go2
m---------salticidae0
-rw-r--r--stream.go8
-rw-r--r--test_msgnet/main.go4
5 files changed, 37 insertions, 5 deletions
diff --git a/event.go b/event.go
index 93b9255..e4ed463 100644
--- a/event.go
+++ b/event.go
@@ -11,6 +11,34 @@ func (self EventContext) Free() { C.eventcontext_free(self) }
func (self EventContext) Dispatch() { C.eventcontext_dispatch(self) }
func (self EventContext) Stop() { C.eventcontext_stop(self) }
+type ThreadCall = *C.struct_threadcall_t
+type ThreadCallCallback = C.threadcall_callback_t
+
+func NewThreadCall(ec EventContext) ThreadCall { return C.threadcall_new(ec) }
+
+func (self ThreadCall) Free() { C.threadcall_free(self) }
+
+func (self ThreadCall) AsyncCall(callback ThreadCallCallback, userdata rawptr_t) {
+ C.threadcall_async_call(self, callback, userdata)
+}
+
+func (self ThreadCall) GetEC() EventContext { return C.threadcall_get_ec(self) }
+
+type TimerEvent = *C.timerev_t
+type TimerEventCallback = C.timerev_callback_t
+
+func NewTimerEvent(ec EventContext, cb TimerEventCallback) TimerEvent {
+ return C.timerev_new(ec, cb)
+}
+
+func (self TimerEvent) Free() { C.timerev_free(self) }
+func (self TimerEvent) SetCallback(callback TimerEventCallback) {
+ C.timerev_set_callback(self, callback)
+}
+
+func (self TimerEvent) Add(t_sec float64) { C.timerev_add(self, C.double(t_sec)) }
+func (self TimerEvent) Clear() { C.timerev_clear(self) }
+
type SigEvent = *C.sigev_t
type SigEventCallback = C.sigev_callback_t
var SIGTERM = C.SIGTERM
diff --git a/netaddr.go b/netaddr.go
index 37ead1e..0a8af8b 100644
--- a/netaddr.go
+++ b/netaddr.go
@@ -14,3 +14,5 @@ func NewAddrFromIPPortString(addr string) (res NetAddr) {
}
func (self NetAddr) Free() { C.netaddr_free(self) }
+
+func (self NetAddr) IsEq(other NetAddr) bool { return bool(C.netaddr_is_eq(self, other)) }
diff --git a/salticidae b/salticidae
-Subproject 1f5bffd006ef432a2fa12fe5baf03c7160c42f7
+Subproject 66c711cf653b082ae07e1119417dcb3461039c8
diff --git a/stream.go b/stream.go
index 2727565..1e7860f 100644
--- a/stream.go
+++ b/stream.go
@@ -8,6 +8,10 @@ type ByteArray = *C.struct_bytearray_t
func NewByteArray() ByteArray { return C.bytearray_new() }
func (self ByteArray) Free() { C.bytearray_free(self) }
+func NewByteArrayMovedFromDataStream(src DataStream) ByteArray {
+ return C.bytearray_new_moved_from_datastream(src)
+}
+
type DataStream = *C.struct_datastream_t
func NewDataStream() DataStream { return C.datastream_new() }
@@ -82,7 +86,3 @@ func (self UInt256) Unserialize(s DataStream) { C.uint256_unserialize(self, s) }
func (self DataStream) GetHash() UInt256 {
return C.datastream_get_hash(self)
}
-
-func (_moved_self DataStream) ToByteArray() ByteArray {
- return C.datastream_to_bytearray(_moved_self)
-}
diff --git a/test_msgnet/main.go b/test_msgnet/main.go
index f1d82dc..4158376 100644
--- a/test_msgnet/main.go
+++ b/test_msgnet/main.go
@@ -37,7 +37,9 @@ func msgHelloSerialize(name string, text string) salticidae.Msg {
serialized.PutData(t)
serialized.PutData([]byte(name))
serialized.PutData([]byte(text))
- return salticidae.NewMsg(MSG_OPCODE_HELLO, serialized.ToByteArray())
+ return salticidae.NewMsg(
+ MSG_OPCODE_HELLO,
+ salticidae.NewByteArrayFromDataStreamByMove(serialized))
}
func msgHelloUnserialize(msg salticidae.Msg) MsgHello {