diff options
author | 2015-03-28 01:46:00 -0700 | |
---|---|---|
committer | 2015-04-10 11:23:42 -0700 | |
commit | 6de558f9cdd54fedbd7b1b1bb16e95023e3193bc (patch) | |
tree | 0cbfc8a2b9d28ea5cf9c28e503796824c5b6b074 /src/ruby/ext/grpc/rb_completion_queue.c | |
parent | 6b493a33534ec5235e5907f75b4f925b97622755 (diff) |
Exposes the implementation of CompletionQueue#pluck
- allows it to be used from other files, e.g, in Call#run_batch
- this keeps code related to releasing the GIL during #pluck in one place
Diffstat (limited to 'src/ruby/ext/grpc/rb_completion_queue.c')
-rw-r--r-- | src/ruby/ext/grpc/rb_completion_queue.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/ruby/ext/grpc/rb_completion_queue.c b/src/ruby/ext/grpc/rb_completion_queue.c index 3fdbdd837a..215de99c29 100644 --- a/src/ruby/ext/grpc/rb_completion_queue.c +++ b/src/ruby/ext/grpc/rb_completion_queue.c @@ -140,8 +140,19 @@ static VALUE grpc_rb_completion_queue_next(VALUE self, VALUE timeout) { /* Blocks until the next event for given tag is available, and returns the * event. */ -static VALUE grpc_rb_completion_queue_pluck(VALUE self, VALUE tag, - VALUE timeout) { +VALUE grpc_rb_completion_queue_pluck(VALUE self, VALUE tag, + VALUE timeout) { + grpc_event *ev = grpc_rb_completion_queue_pluck_event(self, tag, timeout); + if (ev == NULL) { + return Qnil; + } + return grpc_rb_new_event(ev); +} + +/* Blocks until the next event for given tag is available, and returns the + * event. */ +grpc_event* grpc_rb_completion_queue_pluck_event(VALUE self, VALUE tag, + VALUE timeout) { next_call_stack next_call; MEMZERO(&next_call, next_call_stack, 1); Data_Get_Struct(self, grpc_completion_queue, next_call.cq); @@ -151,9 +162,9 @@ static VALUE grpc_rb_completion_queue_pluck(VALUE self, VALUE tag, rb_thread_call_without_gvl(grpc_rb_completion_queue_pluck_no_gil, (void *)&next_call, NULL, NULL); if (next_call.event == NULL) { - return Qnil; + return NULL; } - return grpc_rb_new_event(next_call.event); + return next_call.event; } /* rb_cCompletionQueue is the ruby class that proxies grpc_completion_queue. */ |