Comments (7)
Thanks, I think that's a good point. The xferDoneMap entry is overwritten by the alloc that happens to return the same pointer that was already freed and not yet removed. And I think it might happen more frequently than I initially thought, if only because the lock might hold the goroutine at that exact point. So the probability goes up as you start churning more and more transfers.
I'll send a fix. Did you encounter this problem in practice? The basic Read/Write is very inefficient because it allocates a new transfer for every single operation and there's no way to queue them up other than parallelizing around your Reads. We now have a streaming interface for reads, which allocates a ring buffer of transfers and keeps multiple transfers in flight all the time. It reduces the overhead of memory allocation and interval between subsequent transfers. If you haven't tried it yet, I'd encourage you to give it a go. We don't have a Write stream implementation yet, but it could be added too.
from gousb.
Thanks for the info!
I did indeed run into this problem in practice when multiple goroutines were used for optimizing performance. I was unaware of the streaming API, and once the write stream implementation is completed, this does indeed sound like a preferable option.
from gousb.
Just gave the read stream interface a shot and indeed works great, without worrying about packets reordering, etc :)
from gousb.
May I ask what USB device you're using for continuous writing? I have multiple devices from which I can read in streams, like a USB camera, but I don't have good use cases for writes that I could try out myself.
from gousb.
Fixed by #15.
from gousb.
For write test cases, you could use Android's AOA (https://source.android.com/devices/accessories/protocol), and there are some small examples on github if you don't feel like writing your own Android app for that.
from gousb.
#19 implements a write stream.
from gousb.
Related Issues (20)
- Clear installation of Gosub on the Windows 10 - using msys64 HOT 3
- Latest package not picked up by go get HOT 9
- I can't open hp printer device with gousb HOT 7
- why connect printer return code -5? HOT 1
- Linux: How to get block devices list provided by usb stick? HOT 1
- incorrect device class HOT 2
- WinUSB drivers HOT 3
- libusb: bad access [code -3] HOT 8
- Windows: go build github.com/google/gousb: C:\Program Files\Go\pkg\tool\windows_amd64\cgo.exe: exit status 2 HOT 1
- Can't detach kernel driver. Invalid param [code -2] for iOS 16 devices HOT 5
- How to use in a Docker container without --privileged HOT 1
- CDC device HOT 5
- Cannot claim interface even when there are no other apps are using the device HOT 6
- Status of the tag v2.1.0 HOT 1
- Error claiming interface HOT 5
- Error when WriteContext is called HOT 10
- Device detach: libusb: error [darwin_claim_interface] USBInterfaceOpen: another process has device opened for exclusive access HOT 3
- Memory Leak in CGO part HOT 1
- Memory Leak HOT 4
- Android Support HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gousb.