[solved] Data transfer from C callback to Rust iterator


I am writing a Rust wrapper for libairspy. It is a C library for controlling software defined radio called Airspy.

With this commit I added initial support for getting IQ data samples out of callback.
It works, but it is not safe and should be rewritten.

I would like to get some suggestions how message passing from C callback to Iterator should be rewritten.
Currently it is done like this.

Semaphore is not stable in Rust 1.1 therefore I am using ipc::Semaphore. However I did not quite figure out how to use it for implementing double buffering producer/consumer.


I resolved it with using std::sync::mpsc channel: https://github.com/cubehub/rust-airspy/commit/2721b739dccf14293f0685e3b6d5e8277943b7e1

Now it should be safe to transfer samples out of C callback to the iterator.