kevinmehall / rust-soapysdr

Rust bindings for SoapySDR, the vendor-neutral software defined radio hardware abstraction layer
Apache License 2.0
75 stars 22 forks source link

Add reference counting for Device, allow cloning, drop when refs will be zero. #10

Closed jboone closed 5 years ago

jboone commented 5 years ago

This should address issue #9, with the caveat that I'm very new to and bad at Rust. It seems to work for me though!

jboone commented 5 years ago

Thanks for the thorough review!

I'll admit my PR was after a few frustrated hours learning more about lifetimes and Rc/Arc. I was excited when I got something that worked and made sense to me. I did try at some point to wrap the raw pointer, but I was having so much other trouble that I undid it and then forgot about it.

Anyway, the changes you requested turned out to be surprisingly easy and work fine in my quite limited testing.

jboone commented 5 years ago

Also, sorry for the force-push. I was untidy with my branching, and needed to move another commit off master to keep this PR clean. I'll do better with branching for PRs next time...