vert.x icon indicating copy to clipboard operation
vert.x copied to clipboard

Modify ExecutorServiceFactory API to provide a way to distinguish between pool types

Open kenfinnigan opened this issue 3 years ago • 5 comments

Describe the feature

When ExecutorServiceFactory.createExecutor() is called, provide a method on the API to distinguish the type of executor being created. Maybe it's as simple as passing the name the ThreadFactory is created with?

Use cases

In Quarkus we want the ability to replace the default Executor in some situations, such as the Vert.x worker thread pool, with a shared pool we've created, but other pools create their own Executor instance.

Contribution

Happy to contribute a PR once it's determined the best way to provide an indicator to differentiate the pool types

kenfinnigan avatar May 19 '21 15:05 kenfinnigan

@dmlloyd @stuartwdouglas would appreciate you adding your thoughts around this.

kenfinnigan avatar May 19 '21 15:05 kenfinnigan

can you elaborate about how the factory will be used ?

vietj avatar May 19 '21 15:05 vietj

For instance in Quarkus, we want to use the same executor pool for Vert.x worker threads as we do for worker threads in Quarkus.

Right now there isn't a reliable way for Quarkus to know through the current SPI as to what pool an executor is being created for. In Quarkus we'd want to provide that pool to Vert.x rather than have another one created

kenfinnigan avatar May 19 '21 17:05 kenfinnigan

Have you looked at VertxInternal#getWorkerPool() method ?

vietj avatar May 20 '21 07:05 vietj

At present we're wanting to change the Vert.x worker pool to use an Executor from another project, so we've implemented ExecutorServiceFactory to provide the instance to Vert.x when it's creating the pools.

The issue is that createExecutor() doesn't provide any indication of which pool type an executor is being created for? Whether it's the worker pool, internal blocking pool, or the shared one.

When it's the worker pool, we want to ensure that Vert.x and Quarkus extensions are using the same executor, so we need a way to know in the factory which type of pool is being created. For now we can use a counter and if it's the first executor being created with the factory, we know it's the worker pool executor being created

kenfinnigan avatar May 20 '21 18:05 kenfinnigan