Skip to content

deferred API: global executor  #488

@jknack

Description

@jknack
{
   executor(new ForkJoinPool());

   get("/deferred", promise(deferred -> {
     // run inside fork join pool
   }));
}

Default executor will be set to adirect executor or an executor that runs in the caller thread. This is possible bc Jooby worker threads are allowed to run blocking code as long you set/find an appropriate thread pool (default is 100 threads)

Without an executor the following routes are equivalent (they run in the same thread)

{

   get("/deferred", promise(deferred -> {
     // run in caller thread
     deferred.resolve("OK");
   }));

  get("/deferred", () -> {
     // run in caller thread
     return "OK";
   });
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions