mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-19 18:03:50 +00:00
ZMQII-77: Put librbzmq symbols into ZMQ module
This commit is contained in:
parent
1e7878489d
commit
33cb20a747
1
AUTHORS
1
AUTHORS
@ -4,6 +4,7 @@ Contributors
|
|||||||
Alexej Lotz
|
Alexej Lotz
|
||||||
Asko Kauppi
|
Asko Kauppi
|
||||||
Barak Amar
|
Barak Amar
|
||||||
|
Chris Wong
|
||||||
Conrad D. Steenberg
|
Conrad D. Steenberg
|
||||||
Dhruva Krishnamurthy
|
Dhruva Krishnamurthy
|
||||||
Dirk O. Kaar
|
Dirk O. Kaar
|
||||||
|
@ -69,8 +69,8 @@ static VALUE socket_initialize (VALUE self_, VALUE context_, VALUE type_)
|
|||||||
{
|
{
|
||||||
assert (!DATA_PTR (self_));
|
assert (!DATA_PTR (self_));
|
||||||
|
|
||||||
if (strcmp (rb_obj_classname (context_), "Context") != 0) {
|
if (strcmp (rb_obj_classname (context_), "ZMQ::Context") != 0) {
|
||||||
rb_raise (rb_eArgError, "expected Context object");
|
rb_raise (rb_eArgError, "expected ZMQ::Context object");
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,12 +234,15 @@ static VALUE socket_recv (VALUE self_, VALUE flags_)
|
|||||||
|
|
||||||
extern "C" void Init_librbzmq ()
|
extern "C" void Init_librbzmq ()
|
||||||
{
|
{
|
||||||
VALUE context_type = rb_define_class ("Context", rb_cObject);
|
VALUE zmq_module = rb_define_module ("ZMQ");
|
||||||
|
VALUE context_type = rb_define_class_under (zmq_module, "Context",
|
||||||
|
rb_cObject);
|
||||||
rb_define_alloc_func (context_type, context_alloc);
|
rb_define_alloc_func (context_type, context_alloc);
|
||||||
rb_define_method (context_type, "initialize",
|
rb_define_method (context_type, "initialize",
|
||||||
(VALUE(*)(...)) context_initialize, 3);
|
(VALUE(*)(...)) context_initialize, 3);
|
||||||
|
|
||||||
VALUE socket_type = rb_define_class ("Socket", rb_cObject);
|
VALUE socket_type = rb_define_class_under (zmq_module, "Socket",
|
||||||
|
rb_cObject);
|
||||||
rb_define_alloc_func (socket_type, socket_alloc);
|
rb_define_alloc_func (socket_type, socket_alloc);
|
||||||
rb_define_method (socket_type, "initialize",
|
rb_define_method (socket_type, "initialize",
|
||||||
(VALUE(*)(...)) socket_initialize, 2);
|
(VALUE(*)(...)) socket_initialize, 2);
|
||||||
@ -256,31 +259,31 @@ extern "C" void Init_librbzmq ()
|
|||||||
rb_define_method (socket_type, "recv",
|
rb_define_method (socket_type, "recv",
|
||||||
(VALUE(*)(...)) socket_recv, 1);
|
(VALUE(*)(...)) socket_recv, 1);
|
||||||
|
|
||||||
rb_define_global_const ("HWM", INT2NUM (ZMQ_HWM));
|
rb_define_const (zmq_module, "HWM", INT2NUM (ZMQ_HWM));
|
||||||
rb_define_global_const ("LWM", INT2NUM (ZMQ_LWM));
|
rb_define_const (zmq_module, "LWM", INT2NUM (ZMQ_LWM));
|
||||||
rb_define_global_const ("SWAP", INT2NUM (ZMQ_SWAP));
|
rb_define_const (zmq_module, "SWAP", INT2NUM (ZMQ_SWAP));
|
||||||
rb_define_global_const ("AFFINITY", INT2NUM (ZMQ_AFFINITY));
|
rb_define_const (zmq_module, "AFFINITY", INT2NUM (ZMQ_AFFINITY));
|
||||||
rb_define_global_const ("IDENTITY", INT2NUM (ZMQ_IDENTITY));
|
rb_define_const (zmq_module, "IDENTITY", INT2NUM (ZMQ_IDENTITY));
|
||||||
rb_define_global_const ("SUBSCRIBE", INT2NUM (ZMQ_SUBSCRIBE));
|
rb_define_const (zmq_module, "SUBSCRIBE", INT2NUM (ZMQ_SUBSCRIBE));
|
||||||
rb_define_global_const ("UNSUBSCRIBE", INT2NUM (ZMQ_UNSUBSCRIBE));
|
rb_define_const (zmq_module, "UNSUBSCRIBE", INT2NUM (ZMQ_UNSUBSCRIBE));
|
||||||
rb_define_global_const ("RATE", INT2NUM (ZMQ_RATE));
|
rb_define_const (zmq_module, "RATE", INT2NUM (ZMQ_RATE));
|
||||||
rb_define_global_const ("RECOVERY_IVL", INT2NUM (ZMQ_RECOVERY_IVL));
|
rb_define_const (zmq_module, "RECOVERY_IVL", INT2NUM (ZMQ_RECOVERY_IVL));
|
||||||
rb_define_global_const ("MCAST_LOOP", INT2NUM (ZMQ_MCAST_LOOP));
|
rb_define_const (zmq_module, "MCAST_LOOP", INT2NUM (ZMQ_MCAST_LOOP));
|
||||||
rb_define_global_const ("SNDBUF", INT2NUM (ZMQ_SNDBUF));
|
rb_define_const (zmq_module, "SNDBUF", INT2NUM (ZMQ_SNDBUF));
|
||||||
rb_define_global_const ("RCVBUF", INT2NUM (ZMQ_RCVBUF));
|
rb_define_const (zmq_module, "RCVBUF", INT2NUM (ZMQ_RCVBUF));
|
||||||
|
|
||||||
rb_define_global_const ("NOBLOCK", INT2NUM (ZMQ_NOBLOCK));
|
rb_define_const (zmq_module, "NOBLOCK", INT2NUM (ZMQ_NOBLOCK));
|
||||||
rb_define_global_const ("NOFLUSH", INT2NUM (ZMQ_NOFLUSH));
|
rb_define_const (zmq_module, "NOFLUSH", INT2NUM (ZMQ_NOFLUSH));
|
||||||
|
|
||||||
rb_define_global_const ("P2P", INT2NUM (ZMQ_P2P));
|
rb_define_const (zmq_module, "P2P", INT2NUM (ZMQ_P2P));
|
||||||
rb_define_global_const ("SUB", INT2NUM (ZMQ_SUB));
|
rb_define_const (zmq_module, "SUB", INT2NUM (ZMQ_SUB));
|
||||||
rb_define_global_const ("PUB", INT2NUM (ZMQ_PUB));
|
rb_define_const (zmq_module, "PUB", INT2NUM (ZMQ_PUB));
|
||||||
rb_define_global_const ("REQ", INT2NUM (ZMQ_REQ));
|
rb_define_const (zmq_module, "REQ", INT2NUM (ZMQ_REQ));
|
||||||
rb_define_global_const ("REP", INT2NUM (ZMQ_REP));
|
rb_define_const (zmq_module, "REP", INT2NUM (ZMQ_REP));
|
||||||
rb_define_global_const ("XREQ", INT2NUM (ZMQ_XREQ));
|
rb_define_const (zmq_module, "XREQ", INT2NUM (ZMQ_XREQ));
|
||||||
rb_define_global_const ("XREP", INT2NUM (ZMQ_XREP));
|
rb_define_const (zmq_module, "XREP", INT2NUM (ZMQ_XREP));
|
||||||
rb_define_global_const ("UPSTREAM", INT2NUM (ZMQ_UPSTREAM));
|
rb_define_const (zmq_module, "UPSTREAM", INT2NUM (ZMQ_UPSTREAM));
|
||||||
rb_define_global_const ("DOWNSTREAM", INT2NUM (ZMQ_DOWNSTREAM));
|
rb_define_const (zmq_module, "DOWNSTREAM", INT2NUM (ZMQ_DOWNSTREAM));
|
||||||
|
|
||||||
rb_define_global_const ("POLL", INT2NUM (ZMQ_POLL));
|
rb_define_const (zmq_module, "POLL", INT2NUM (ZMQ_POLL));
|
||||||
}
|
}
|
||||||
|
@ -27,8 +27,8 @@ bind_to = ARGV[0]
|
|||||||
message_size = ARGV[1].to_i
|
message_size = ARGV[1].to_i
|
||||||
roundtrip_count = ARGV[2].to_i
|
roundtrip_count = ARGV[2].to_i
|
||||||
|
|
||||||
ctx = Context.new(1, 1, 0)
|
ctx = ZMQ::Context.new(1, 1, 0)
|
||||||
s = Socket.new(ctx, REP);
|
s = ZMQ::Socket.new(ctx, ZMQ::REP);
|
||||||
s.bind(bind_to);
|
s.bind(bind_to);
|
||||||
|
|
||||||
for i in 0...roundtrip_count do
|
for i in 0...roundtrip_count do
|
||||||
|
@ -27,9 +27,9 @@ bind_to = ARGV[0]
|
|||||||
message_size = ARGV[1].to_i
|
message_size = ARGV[1].to_i
|
||||||
message_count = ARGV[2].to_i
|
message_count = ARGV[2].to_i
|
||||||
|
|
||||||
ctx = Context.new(1, 1, 0)
|
ctx = ZMQ::Context.new(1, 1, 0)
|
||||||
s = Socket.new(ctx, SUB);
|
s = ZMQ::Socket.new(ctx, ZMQ::SUB);
|
||||||
s.setsockopt(SUBSCRIBE, "");
|
s.setsockopt(ZMQ::SUBSCRIBE, "");
|
||||||
|
|
||||||
# Add your socket options here.
|
# Add your socket options here.
|
||||||
# For example ZMQ_RATE, ZMQ_RECOVERY_IVL and ZMQ_MCAST_LOOP for PGM.
|
# For example ZMQ_RATE, ZMQ_RECOVERY_IVL and ZMQ_MCAST_LOOP for PGM.
|
||||||
|
@ -27,8 +27,8 @@ connect_to = ARGV[0]
|
|||||||
message_size = ARGV[1].to_i
|
message_size = ARGV[1].to_i
|
||||||
roundtrip_count = ARGV[2].to_i
|
roundtrip_count = ARGV[2].to_i
|
||||||
|
|
||||||
ctx = Context.new(1, 1, 0)
|
ctx = ZMQ::Context.new(1, 1, 0)
|
||||||
s = Socket.new(ctx, REQ);
|
s = ZMQ::Socket.new(ctx, ZMQ::REQ);
|
||||||
s.connect(connect_to);
|
s.connect(connect_to);
|
||||||
|
|
||||||
msg = "#{'0'*message_size}"
|
msg = "#{'0'*message_size}"
|
||||||
|
@ -27,8 +27,8 @@ connect_to = ARGV[0]
|
|||||||
message_size = ARGV[1].to_i
|
message_size = ARGV[1].to_i
|
||||||
message_count = ARGV[2].to_i
|
message_count = ARGV[2].to_i
|
||||||
|
|
||||||
ctx = Context.new(1, 1, 0)
|
ctx = ZMQ::Context.new(1, 1, 0)
|
||||||
s = Socket.new(ctx, PUB);
|
s = ZMQ::Socket.new(ctx, ZMQ::PUB);
|
||||||
|
|
||||||
# Add your socket options here.
|
# Add your socket options here.
|
||||||
# For example ZMQ_RATE, ZMQ_RECOVERY_IVL and ZMQ_MCAST_LOOP for PGM.
|
# For example ZMQ_RATE, ZMQ_RECOVERY_IVL and ZMQ_MCAST_LOOP for PGM.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user