-
Notifications
You must be signed in to change notification settings - Fork 85
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
Async Idea #47
Comments
A few more comments on the |
You don't need any permission for this. You can create fork and push any branch to it. |
Ok. Cool. I didn't know that. Just created one :) |
I've got an idea on how to make the async API work. I've got it working on a local branch and it seems to be working pretty well. It basically revolves around a struct that looks like this:
The
buff
vector is the vector where libusb puts the data.ptr
is the transfer struct provided by libusb.recv
is where we accumulate the results.TransferStatus
looks like this:The callback function is a private function inside
impl AsynTransfer
and looks like this:Basically, it puts the result into a
VecDeque
and the scope that owns the struct can process these whenever it wants. This is not threadsafe, but doesn't pretend to be. If you try to make this structSend
orSync
, the compiler gives an error. The callback function runs in the same thread that created the struct when you calllibusb1_sys::libusb_handle_events
.Like I said, I've been testing it and it seems to work pretty well. If you're interested, I'll push the branch and create a pull request if you give me the permissions I need.
The text was updated successfully, but these errors were encountered: