aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ruby
diff options
context:
space:
mode:
authorGravatar Craig Tiller <craig.tiller@gmail.com>2015-05-11 09:02:07 -0700
committerGravatar Craig Tiller <craig.tiller@gmail.com>2015-05-11 09:02:07 -0700
commit3a4880856a9d1e19b51aa49f34c80bb9062d888d (patch)
treee75e6ba4effb7e7352636afbf3b2f7563ce7a58b /src/ruby
parentc7313235f88c2515475c973f7829f6fbeee6415e (diff)
Ruby progress
Diffstat (limited to 'src/ruby')
-rw-r--r--src/ruby/ext/grpc/rb_completion_queue.c19
-rw-r--r--src/ruby/ext/grpc/rb_completion_queue.h4
2 files changed, 7 insertions, 16 deletions
diff --git a/src/ruby/ext/grpc/rb_completion_queue.c b/src/ruby/ext/grpc/rb_completion_queue.c
index 3cf6c313ee..cef8cd75d2 100644
--- a/src/ruby/ext/grpc/rb_completion_queue.c
+++ b/src/ruby/ext/grpc/rb_completion_queue.c
@@ -47,7 +47,7 @@ static VALUE grpc_rb_cCompletionQueue = Qnil;
/* Used to allow grpc_completion_queue_next call to release the GIL */
typedef struct next_call_stack {
grpc_completion_queue *cq;
- grpc_event *event;
+ grpc_event event;
gpr_timespec timeout;
void *tag;
} next_call_stack;
@@ -145,12 +145,9 @@ static VALUE grpc_rb_completion_queue_next(VALUE self, VALUE timeout) {
TypedData_Get_Struct(self, grpc_completion_queue,
&grpc_rb_completion_queue_data_type, next_call.cq);
next_call.timeout = grpc_rb_time_timeval(timeout, /* absolute time*/ 0);
- next_call.event = NULL;
+ next_call.event.type = GRPC_QUEUE_TIMEOUT;
rb_thread_call_without_gvl(grpc_rb_completion_queue_next_no_gil,
(void *)&next_call, NULL, NULL);
- if (next_call.event == NULL) {
- return Qnil;
- }
return grpc_rb_new_event(next_call.event);
}
@@ -158,17 +155,14 @@ static VALUE grpc_rb_completion_queue_next(VALUE self, VALUE timeout) {
* event. */
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;
- }
+ grpc_event ev = grpc_rb_completion_queue_pluck_event(self, tag, timeout);
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) {
+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);
TypedData_Get_Struct(self, grpc_completion_queue,
@@ -178,9 +172,6 @@ grpc_event* grpc_rb_completion_queue_pluck_event(VALUE self, VALUE tag,
next_call.event = NULL;
rb_thread_call_without_gvl(grpc_rb_completion_queue_pluck_no_gil,
(void *)&next_call, NULL, NULL);
- if (next_call.event == NULL) {
- return NULL;
- }
return next_call.event;
}
diff --git a/src/ruby/ext/grpc/rb_completion_queue.h b/src/ruby/ext/grpc/rb_completion_queue.h
index 4d0f49ac47..e4d04b10c8 100644
--- a/src/ruby/ext/grpc/rb_completion_queue.h
+++ b/src/ruby/ext/grpc/rb_completion_queue.h
@@ -45,8 +45,8 @@ grpc_completion_queue *grpc_rb_get_wrapped_completion_queue(VALUE v);
*
* This avoids having code that holds the GIL repeated at multiple sites.
*/
-grpc_event* grpc_rb_completion_queue_pluck_event(VALUE cqueue, VALUE tag,
- VALUE timeout);
+grpc_event grpc_rb_completion_queue_pluck_event(VALUE cqueue, VALUE tag,
+ VALUE timeout);
/* Initializes the CompletionQueue class. */
void Init_grpc_completion_queue();