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