GithubHelp home page GithubHelp logo

Comments (4)

mxk avatar mxk commented on May 20, 2024 1

I see your point, but these decisions were already made by libusb authors, so I would say that a wrapper shouldn't place additional restrictions. Rather, it should do whatever libusb would do if reset is called in parallel with other operations, assuming that such use is valid.

In my case, I wrote a wrapper around libusb's async transfer API, which required putting the DeviceHandle behind an Arc, but then needed access to some of the &mut self methods elsewhere. Worked around it with unsafe, but didn't see a good reason why that should be needed. I can also envision use cases where you actually do want to reset the device while other things are happening to implement watchdog-like functionality.

from rusb.

a1ien avatar a1ien commented on May 20, 2024

You can share DeviceHandle with Arc even some of function take &mut self. I think it's good protection to call this function if you own DeviceHandle. No one prevent you share DeviceHandle with Arc and call write_bulk/read_bulk from multiply thread. But what happened if you read or write in one thread and try to reset or clear_halt in other. And that's why these functions take &mut self.
We can discuss how this should be handled.

from rusb.

a1ien avatar a1ien commented on May 20, 2024

Ok. I am agree. I will try to make new update for library. But I think it will be at the end of October or begin November. It will be breaking changes.

from rusb.

mcuee avatar mcuee commented on May 20, 2024

Just take note libusb_reset() behavior is platform dependant. Under Windows it may be even driver dependant. libusb gives the freedom to the user and user can shoot themselves by calling libusb_reet() in a multithread application.

As for rusb, I think it does not really need to follow libusb in this aspect.

from rusb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.