Created
September 27, 2012 19:26
-
-
Save jesse99/3795931 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type SamplesFn = fn~ (samples: &RingBuffer); | |
enum Msg | |
{ | |
GetSamples(~str, SamplesFn), // sample set name, callback which receives samples | |
} | |
fn manage_samples(port: comm::Port<Msg>) | |
{ | |
let sample_sets = std::map::HashMap(); | |
loop | |
{ | |
match comm::recv(port) | |
{ | |
GetSamples(copy name, ref callback) => | |
{ | |
let buffer = sample_sets[@name]; | |
(*callback)(buffer); | |
} | |
} | |
} | |
} | |
do task::spawn | |
|copy name| | |
{ | |
let callback: samples::SamplesFn = | |
|buffer| | |
{ | |
for buffer.len().timesi |i| {error!("%?: %f", i, buffer[i])} | |
}; | |
samples_chan.send(samples::GetSamples(copy name, callback)); | |
}; | |
mismatched types: | |
expected `samples::SamplesFn` | |
but found `fn~(&ring_buffer::RingBuffer)` | |
(lifetime mismatch) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment