class Poller[A]
One parked take (Effect's Deferred in a pollers list).
Functions#
__init__#
__init__(pollers) -> None| Parameter | Type | Description |
|---|---|---|
pollers | Pollers[A] |
def __init__(self, pollers: Pollers[A]) -> None:
self._pollers = pollers
self._wake: Callable[[], None] = _not_parked
self._state = _PENDING
self._cause: Cause[Never] | None = Nonesucceed#
succeed(value) -> boolGive the take value and wake it. False, keeping nothing,
if the take was already completed or has ended.
| Parameter | Type | Description |
|---|---|---|
value | A |
Returns bool
def succeed(self, value: A) -> bool:
"""Give the take ``value`` and wake it. ``False``, keeping nothing,
if the take was already completed or has ended."""
if self._state != _PENDING:
return False
self._pollers._reserved.append(value)
self._state = _RESERVED
self._wake()
return Truedone#
done(exit) -> boolEnd the take with exit: succeed its value, or fail it
with its cause (an interrupt, a defect).
| Parameter | Type | Description |
|---|---|---|
exit | Exit[A, Never] |
Returns bool
def done(self, exit: Exit[A, Never]) -> bool:
"""End the take with ``exit``: ``succeed`` its value, or fail it
with its cause (an interrupt, a defect)."""
if isinstance(exit, Success):
return self.succeed(exit.value)
if self._state != _PENDING:
return False
self._cause = exit.cause
self._state = _FAILED
self._wake()
return True