libxev icon indicating copy to clipboard operation
libxev copied to clipboard

Simple question

Open Pismice opened this issue 1 year ago • 1 comments

Hello,

First let me just say that I am sorry because it probably isnt the place to ask such questions but I didnt find any other :(

My question is: can the completions be compared to green threads or did I misunderstand something ?

Sorry for the disturbance and I wish you a nice day :smiley:

Pismice avatar Apr 03 '24 13:04 Pismice

Someone correct me if I'm wrong but to my understanding in general green threads are something different beyond that they both provide an async programming model. Green threads provide a concurrent programming model by essentially providing "virtual" threads to execute arbitrary units of work. The virtual threads are scheduled by the runtime on the same thread and/or additional threads (probably on less threads than the number of green/virtual threads) and run in userspace.

What this library (and the underlying APIs this abstracts such as kqueue and io_uring) provide is an asynchronous API for I/O operations and some other system calls. Syscalls are handled by the OS kernel so it's not possible to schedule your own code in this event loop. Essentially it passes a message to the OS kernel to ask it to do some work for you (read from a file for example), and it'll let you know when the requested work has been completed.

gerbyzation avatar Jun 15 '24 17:06 gerbyzation