xiio

really simple async runtime
git clone https://git.ce9e.org/xiio.git

commit
c6b5d2af9309c2bb20c737d7bf2e164d23f56de3
parent
d0bc4771606dc88db648aaa06bd70d87c8929a84
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2026-04-18 18:59
avoid context switch in thread pool

Diffstat

M xiio/core.py 7 +++++--
M xiio/threads.py 2 +-

2 files changed, 6 insertions, 3 deletions


diff --git a/xiio/core.py b/xiio/core.py

@@ -119,13 +119,16 @@ class Future(typing.Generic[T]):
  119   119         self.exc = exc
  120   120         self.done = True
  121   121 
  122    -1     def __await__(self) -> Gen[T]:
  123    -1         yield Condition(futures={self})
   -1   122     def unwrap(self) -> T:
  124   123         if self.exc:
  125   124             raise self.exc
  126   125         else:
  127   126             return typing.cast(T, self.result)
  128   127 
   -1   128     def __await__(self) -> Gen[T]:
   -1   129         yield Condition(futures={self})
   -1   130         return self.unwrap()
   -1   131 
  129   132 
  130   133 class Task(typing.Generic[T]):
  131   134     def __init__(self, gen: Gen[T]):

diff --git a/xiio/threads.py b/xiio/threads.py

@@ -15,7 +15,7 @@ async def future_with_fd(future: Future[T], fd: int) -> T:
   15    15     while not future.done:
   16    16         await Condition(files={fd: READ})
   17    17     os.read(fd, 1)
   18    -1     return await future
   -1    18     return future.unwrap()
   19    19 
   20    20 
   21    21 class ThreadPool: