Wolfgang Pupp wrote:
> I've been working with libusbx for some time now --I'm primarily very
> happy with it-- but one design trait gave me trouble: Being forced to
> use C-callbacks for dealing with asynchronous transfers.
> It would be *really* nice if there was a "push style" API one could
> resort to, 

It's interesting you would call this "push style"; in my mind this is
"pull style", because I have to pull the events from libusbx, instead of
having the library push them to me.


> like this:
>     /* inside the main-loop: */
>     libusb_check_events_timeout_completed(ctx, timeout, &evt_cnt);
>     for(int i = 0; i < evt_cnt; ++i) {
>       libusb_transfer *transfer;
>       libusb_handle_next_transfer(ctx, &transfer);
>       /* do something with the transfer */
>     }

I don't see the point of the added complexity of the event count, which
would be outdated as soon as it was returned.  Why not just:
    libusb_transfer * transfer;
    while( libusb_get_completed_transfer( ctx, timeout, &transfer) ==
some success value )
    {
        // Do something with transfer
    }

In both cases, you'd have to loop back around to check later anyway.

This would not be too hard to add, although I suspect you could do the
same thing yourself with a small C module.

-- 
Tim Roberts, t...@probo.com
Providenza & Boekelheide, Inc.


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel

Reply via email to