2013-05-20 17:07:24 -07:00
|
|
|
extern mod extra;
|
2013-01-03 14:55:46 -08:00
|
|
|
|
2013-05-20 17:07:24 -07:00
|
|
|
use std::comm::Chan;
|
2013-05-24 19:35:29 -07:00
|
|
|
use std::task;
|
2013-01-03 14:55:46 -08:00
|
|
|
|
2013-09-26 02:26:09 -04:00
|
|
|
type RingBuffer = ~[f64];
|
2013-11-18 17:40:54 -08:00
|
|
|
type SamplesFn = proc(samples: &RingBuffer);
|
2013-01-03 14:55:46 -08:00
|
|
|
|
|
|
|
enum Msg
|
|
|
|
{
|
|
|
|
GetSamples(~str, SamplesFn), // sample set name, callback which receives samples
|
|
|
|
}
|
|
|
|
|
|
|
|
fn foo(name: ~str, samples_chan: Chan<Msg>) {
|
|
|
|
do task::spawn
|
|
|
|
{
|
2013-12-05 18:19:06 -08:00
|
|
|
let mut samples_chan = samples_chan;
|
2013-11-21 23:36:52 -08:00
|
|
|
let callback: SamplesFn = proc(buffer) {
|
|
|
|
for i in range(0u, buffer.len()) {
|
|
|
|
error!("{}: {}", i, buffer[i])
|
|
|
|
}
|
|
|
|
};
|
2013-03-15 18:27:15 -04:00
|
|
|
samples_chan.send(GetSamples(name.clone(), callback));
|
2013-01-03 14:55:46 -08:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2013-02-01 19:43:17 -08:00
|
|
|
pub fn main() {}
|