Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide vert.x executor adapter which implements ScheduledExecutorService #5036

Open
codekrolik2 opened this issue Dec 16, 2023 · 7 comments

Comments

@codekrolik2
Copy link

Describe the feature

Vert.x executor has a number of very useful features, notably the ability to detect and address locked threads.
Providing a standard interface for this executor will immensely enhance its utility.

Use cases

e.g. that will add compatibility with Guava ListenableFutures, and all other libraries that use standard java executor.

Contribution

For now I'll just leave this proposal here.

@vietj
Copy link
Member

vietj commented Dec 17, 2023 via email

@codekrolik2
Copy link
Author

Something like this:

    int threadCount = 5;
    //ScheduledExecutorService scheduledExecutor = Executors.newScheduledThreadPool(threadCount);
    ScheduledExecutorService scheduledExecutor = Vertx.vertx();
    ListeningScheduledExecutorService exec = MoreExecutors.listeningDecorator(scheduledExecutor);
    ListenableFuture<Void> unused = Futures.transform(Futures.immediateFuture("Hello world."),
        s -> {
          System.out.println(s);
          return null;
        },
        exec);

@vietj
Copy link
Member

vietj commented Dec 17, 2023

you would like the Vertx interface to extend ScheduledExecutorService ?

@vietj
Copy link
Member

vietj commented Dec 17, 2023

what are the use cases ?

@codekrolik2
Copy link
Author

codekrolik2 commented Dec 17, 2023

you would like the Vertx interface to extend ScheduledExecutorService ?

Either that, or have a way to adapt is to ScheduledExecutorService.

what are the use cases ?

If I'm using standard ScheduledExecutorService, a thread can be blocked, and that's not detected or reported.
Vert.x detects that and prevents blocking.
That's a great property that I'd love to leverage in a lightweight workflow engine project I'm currently working on.
The idea is that the engine should be lightweight, portable and work everywhere, including limited hardware, like android and embedded platforms.
In such environments it's extremely important to minimize the number of used threads, ideally to 1, and if by some programmer's mistake a flow would block a thread - it could severely impact the performance or even completely halt all execution; especially if there is only 1 thread in the pool.

Vert.x provides a great utility in the form of auto-detecting such situations and throwing exceptions / unblocking threads, which also helps to make such hard to detect problems very visible.

@vietj
Copy link
Member

vietj commented Dec 17, 2023

what kind of workload do you want to execute with this executor ?

@codekrolik2
Copy link
Author

codekrolik2 commented Dec 17, 2023

It's a universal programmable workflow engine, it can be used for any type of workloads.
More details here:
https://github.com/ja-css/flower

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants