Hi!

> In general you should not used the no arg version of dispatch(), it has been deprecated as it is not thread safe.
I understand but I have a specific need. So I'm wondering if there are better alternatives.

> If you want to just dispatch some work to a worker using the version that takes a runnable sounds like exactly what you are after, as it will run the runnable in a worker thread.

In fact I want/need a bit more complex thing.
I'm running undertow under Scala within ZIO. Essentially ZIO is a powerful asynchronous framework and it has a lot of async primitives.
So, I wish to efficiently integrate ZIO with undertow. From all I can understand at the moment I have only one option to do it - let undertow block in it's thread pool until my call finishes.

But I want it not to block and just provide me a callback which I may invoke once my logic finishes. And/or a way to return a promise/future/IOFuture back to undertow.

In ideal world I would like to wrap undertow within my runtime so it doesn't manage it's own threadpools (like I can do with http4s) but I guess it's not possible because all the code is monomorphic (and it's java code).

From what I can see there is no way to provide an async request handler at the moment. Maybe I miss something? Or maybe it's possible to add it?

On Wed, Oct 23, 2019 at 11:21 PM Stuart Douglas <sdouglas@redhat.com> wrote:


On Thu, 24 Oct 2019 at 01:23, Pavel Shirshov <pshirshov@gmail.com> wrote:
Hi guys,

Could you give me a hint if there is a way to write asynchronous handlers?
So, I have my own asynchronous runtime (namely ZIO) and I wish undertow's worker thread to do something while it's waiting for request completion after a `dispatch` in my handler.

Is there an API allowing me to return a Future or undertow's IOFuture so I may write an adaptor for my primitives?..

From what I can see there is that zero-arg `.dispatch()` method which just changes internal flag. So, from what I can understand I may just set that flag and then complete my request totally asynchronously. Though that method is marked deprecated without an alternative - other versions also wait for a `Runnable`.

In general you should not used the no arg version of dispatch(), it has been deprecated as it is not thread safe. 

If you want to just dispatch some work to a worker using the version that takes a runnable sounds like exactly what you are after, as it will run the runnable in a worker thread.

Stuart
 

--
Thanks,
    Pavel
_______________________________________________
undertow-dev mailing list
undertow-dev@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/undertow-dev


--
Thanks,
    Pavel