Permalink
Browse files

trying to add a error function method

  • Loading branch information...
1 parent 10e61fa commit f89ce980339a5ef03f1fab74d4648cbc9e1c02c9 @tenderlove committed Sep 22, 2008
Showing with 15 additions and 1 deletion.
  1. +1 −1 example/remote.rb
  2. +6 −0 ext/quail/czmq.cpp
  3. +2 −0 ext/quail/czmq.h
  4. BIN ext/quail/czmq.o
  5. +6 −0 ext/quail/native.c
View
@@ -5,6 +5,6 @@
queue = Quail::Queue.new(handle, 'QG', Quail::GLOBAL)
while true
- handle.receive
+ puts handle.receive
end
end
View
@@ -11,6 +11,7 @@
#include <zmq/poll_thread.hpp>
#include <zmq/api_thread.hpp>
+
struct context_t
{
zmq::locator_t *locator;
@@ -120,3 +121,8 @@ void czmq_receive (void *obj_, void **data_, size_t *size_, czmq_free_fn **ffn_)
*size_ = msg.size ();
*ffn_ = free;
}
+
+void czmq_set_error_handler(error_handler_t func)
+{
+ zmq::set_error_handler(func);
+}
View
@@ -9,6 +9,7 @@ extern "C" {
#define CZMQ_SCOPE_GLOBAL 1
typedef void (czmq_free_fn) (void *data_);
+typedef int (error_handler_t) (const char *local_object_);
void *czmq_create (const char *host_);
void czmq_destroy (void *obj_);
@@ -21,6 +22,7 @@ void czmq_send (void *obj_, int eid_, void *data_, size_t size,
czmq_free_fn *ffn_);
void czmq_receive (void *obj_, void **data_, size_t *size_,
czmq_free_fn **ffn_);
+void czmq_set_error_handler(error_handler_t func);
#ifdef __cplusplus
}
View
Binary file not shown.
View
@@ -1,10 +1,16 @@
#include <native.h>
+static bool awesome (const char *foo)
+{
+ return 0;
+}
+
void Init_native()
{
VALUE mQuail = rb_define_module("Quail");
rb_const_set(mQuail, rb_intern("LOCAL"), INT2NUM(CZMQ_SCOPE_LOCAL));
rb_const_set(mQuail, rb_intern("GLOBAL"), INT2NUM(CZMQ_SCOPE_GLOBAL));
+ czmq_set_error_handler(awesome);
Init_Quail_Handle(mQuail);
Init_Quail_Exchange(mQuail);

0 comments on commit f89ce98

Please sign in to comment.