Skip to content

Commit

Permalink
Return wait_time and use it when yielding
Browse files Browse the repository at this point in the history
  • Loading branch information
kovyrin committed Oct 16, 2024
1 parent 1ce5f4e commit 2c47a84
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions ext/semian/resource.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ semian_resource_acquire_semaphore(int argc, VALUE *argv, VALUE self)
wait_time = LONG2NUM(res.wait_time);
}

return Qnil;
return wait_time;
}

VALUE
Expand All @@ -78,7 +78,7 @@ semian_resource_acquire(int argc, VALUE *argv, VALUE self)
rb_raise(rb_eArgError, "acquire requires a block");
}

semian_resource_acquire_semaphore(argc, argv, self);
VALUE wait_time = semian_resource_acquire_semaphore(argc, argv, self);

return rb_ensure(rb_yield, wait_time, semian_resource_release_semaphore, self);
}
Expand Down
2 changes: 1 addition & 1 deletion ext/semian/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ semian_resource_acquire(int argc, VALUE *argv, VALUE self);

/*
* call-seq:
* resource.acquire_semaphore(timeout: default_timeout) -> nil
* resource.acquire_semaphore(timeout: default_timeout) -> wait_time
*
* Acquires a resource. The call will block for <code>timeout</code> seconds if a ticket
* is not available. If no ticket is available within the timeout period, Semian::TimeoutError
Expand Down

0 comments on commit 2c47a84

Please sign in to comment.