Skip to content
This repository has been archived by the owner on Mar 29, 2022. It is now read-only.

Add timeout option to streambuf #8

Open
malachib opened this issue May 22, 2017 · 1 comment
Open

Add timeout option to streambuf #8

malachib opened this issue May 22, 2017 · 1 comment

Comments

@malachib
Copy link
Owner

malachib commented May 22, 2017

This is decidedly non-standard C++ but important given our deviation in peek behavior

Since our peek is never blocking, things like cin >> ws are less useful. Therefore, make a feature flag which enables a timeoutable peek mode.

Upon doing this we might revisit the code deviation for sgetc behavior and make it blocking again (respecting the timeout) and perhaps implement a new non-standard speekc to feed our istream::peek. This retains the desired deviant behavior but very slightly closes the standards deviation gap itself.

Consider also adding an istream::inspect which I contend is a more invasive act than a peek, suggesting we retain non-standard non-blocking peek behavior and introduce inspect as the blocking version. Alternatively, come up with a verb even less invasive than peek (like maybe anticipate or nonblock_peek or something) and switch peek back to standard behavior

malachib added a commit that referenced this issue May 24, 2017
Maps approximately to #8
@malachib
Copy link
Owner Author

Code now treats peek as either:

  1. Always-blocking (100% standardized behavior)
  2. Timeout-blocking (non standard, but unlikely to break standard code run against it)

Timeout-blocking mode is enabled via FEATURE_IOS_TIMEOUT compiler define, and set it specifically to
the numeric value of milliseconds for the system level timeout. Though a compile-time timeout is somewhat restrictive, it should cover (with the addition of the nonstandard peek(timeout_ms) call) the use cases we're interested in.

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

No branches or pull requests

1 participant