Goals: provide an IO abstraction layer that can be efficiently implemented using differente techniques:
The event channel is the central IO absctraction.
Async requests are posted to the channel as Events. When the request is complete it is returned from getEvent() with the data filled in.
We provide synchronous APIs to wrap post(event), wait for getEvent(). On posix these APIs are actually implemented using user-level context swithching so we get a simple programing model with minimal blocking and kernel context switching.
Note: this means that code before and after an apparently synchronous call ''may execute in different threads''. Don't use thread-local
storage. The term "task" will denote the user-level execution context and we'll provide "task-locak storage" that is carried with the user
context if we need it.
We can provide some simple in-process synchronization via the event channel to allow use level tasks to block on application events.
EventChannel:
Task:
Linux ec_ + ucontext implementation:
Linux epoll + ucontext:
APR portable impl: only need client support - simple blocking socket calls.
Computing thread pool size:
ThreadPool: Size should stay close to actuall hardware paralellism + some delta due to pre-empted threads and thread-blocking
synchronization calls required in the event channel implementation itself.
Questions: