3 ms·
How do you determine whether a method call is thread-blocking or not? Should libraries be quasar-aware to not end up in the IO workers pool when invoked?
by tuxychandru 13y ago
How do you determine whether a method call is thread-blocking or not?
Should libraries be quasar-aware to not end up in the IO workers pool when invoked?
- pron 13y agoEvery fiber-blocking operation eventually ends up with a call to Fiber.park(). If you want to call park in your function or call a function that calls park etc., you need to let Quasar know that your function is "suspendable". There are several ways to do that: you can declare to throw a SuspendExecution exception, you can annotate your method with a @Suspendable annotation, or you could declare it as suspendable programmatically or in an external text file.
- tuxychandru 13y agoAh, so I cannot just use any Java library that performs IO if I have to get quasar's benefits.
- pron 13y agoCorrect, but we'll provide implementations for the most popular IO APIs (NIO, REST services, web sockets, JDBC etc.) so it is a limitation, but I think it's a small one. Once the documentation is complete you'll know how to transform any callback-based asynchronous call into a fiber-blocking one, so you could integrate your own libraries with Quasar. It's very-very simple.