timeout
Fail a task if it doesn't complete within a duration.
Behavior:
- Starts the task and a timer concurrently
- If task completes first, returns its result
- If timer fires first, requests stop for the task and returns error condition
capy::cond::timeout
Real-world use cases:
| Use Case |
Description |
| SLA enforcement |
Ensure responses within promised latency |
| Deadlock prevention |
Abort operations that hang indefinitely |
| Resource protection |
Prevent slow clients from holding resources |
| User experience |
Show timeout message rather than hanging UI |
auto[ec, n] = co_await timeout( sock.read_some( buf ), 50ms );
timeoutFail a task if it doesn't complete within a duration.
Behavior:
capy::cond::timeoutReal-world use cases: