alshdavid / BorrowScript

TypeScript with a Borrow Checker. Multi-threaded, Tiny binaries. No GC. Easy to write.
1.45k stars 16 forks source link

Enforce one event queue per thread #30

Closed Isaac-Leonard closed 2 years ago

Isaac-Leonard commented 3 years ago

In the main README file there's a brief discussion of how the event queue would work with threads. Can I suggest that each thread is given its own event queue and then is given functions to explicitly flush it so that synchronous code can use it without needing to add awaits and promises?

alshdavid commented 2 years ago

Correct, this is how it will work. We would be using the "task stealing queue" strategy from Go and Tokio.

Basically each thread will have an event queue and the tasks will be shuffled around to ensure all the cores are working on tasks.

We target threads and package them into queues, that way the event loop is a library and not a built-in construct.

https://github.com/alshdavid/BorrowScript#concurrency-async--await