Skip to content
This repository has been archived by the owner on Apr 2, 2018. It is now read-only.

Consider generalizing TimeoutStream / adding an IdleStream adapter #35

Open
mehcode opened this issue Nov 19, 2017 · 0 comments
Open

Consider generalizing TimeoutStream / adding an IdleStream adapter #35

mehcode opened this issue Nov 19, 2017 · 0 comments

Comments

@mehcode
Copy link

mehcode commented Nov 19, 2017

In my project I need to execute some action if a stream has not responded for some amount of time and then continue with normal operation of the stream; essentially, an idle callback.

I copied TimeoutStream into my project and modified a few lines. Instead of raising on error on timeout I invoke a closure and resume polling the stream.

// [...]

            Ok(Async::Ready(_)) => {
                // Timeout has elapsed, reest and continue
                self.sleep = self.timer.sleep(self.duration);
                (self.on_idle)();

                self.poll()
            }

// [...]

Would this IdleStream be a good fit for inclusion in this crate ?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant