Created
April 14, 2017 02:56
-
-
Save azriel91/e0084994eb99d84c1ca0a79f1a913bf3 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
let mut collection_buffer = Vec::with_capacity(input_buffer.len()); | |
let mut input_iter = input_buffer.drain(..); | |
loop { | |
if let Some(input) = input_iter.next() { | |
let result = context.as_ref() | |
.unwrap() | |
.listener_tx | |
.send(input); | |
// if we fail to send, it implies the listener has stopped listening | |
// we then buffer all of the input for the next activity | |
if let Err(SendError(missed_input)) = result { | |
collection_buffer.push(missed_input); | |
while let Some(input) = input_iter.next() { | |
collection_buffer.push(input); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment