Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Ruby progress callback + customise our GIL unblock function #151

Merged
merged 12 commits into from
Jan 30, 2018

Conversation

julik
Copy link
Collaborator

@julik julik commented Nov 6, 2017

We should provide some ability for users to re-acquire the GIL and call Ruby callback blocks. We will start with a progress callback which can be used for progress bars and speed computation. We also need to alter the way we unblock the thread so that we correctly handle signals.

This adds the following API:

sess.progress_callback = ->(download_total, download_now, upload_total, upload_now) {
  progress_bar.update(download_total) # ...or other interesting actions
}

The GIL will only be reacquired if this is configured on the Session/Request objects, otherwise we proceed through the same fast path as before with the GIL unlocked.

Closes #150 and paves the way for making #139 possible

julik added 4 commits November 6, 2017 20:47
Work in progress - for now we will print from it to see if
it properly gets invoked by the VM
For now - as a Proc you return from Request
@julik
Copy link
Collaborator Author

julik commented Nov 6, 2017

#150 and should open the door for #139 (because we need to manage the GIL very carefully for these). Also is going to allow programmatic abort from a callback proc, which can be a neat feature to have.

@julik
Copy link
Collaborator Author

julik commented Nov 23, 2017

@marshall-lee since you stumbled upon this anyway - have you got an idea what I should use instead of rb_thread_call_with_gvl when we only have rb_thread_blocking_region available (for pre-2.2 Rubies). I've been looking around but it seems all the docs online now only mention rb_thread_blocking_region being removed.

@julik julik changed the title WIP: Customized unblock function + Ruby progress callbacks Add Ruby progress callback + customise our GIL unblock function Jan 29, 2018
@julik julik requested a review from toland January 29, 2018 13:50
@julik
Copy link
Collaborator Author

julik commented Jan 30, 2018

@toland ?

@toland
Copy link
Owner

toland commented Jan 30, 2018

LGTM.

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@julik julik merged commit ba2161c into master Jan 30, 2018
@julik julik deleted the progress-callback branch February 2, 2018 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants