Skip to content

add jvmLaunchers#345

Closed
harbby wants to merge 4 commits intoapache:masterfrom
harbby:master
Closed

add jvmLaunchers#345
harbby wants to merge 4 commits intoapache:masterfrom
harbby:master

Conversation

@harbby
Copy link
Copy Markdown

@harbby harbby commented Aug 23, 2018

When you need to perform some operations through a child process, it is very cumbersome and requires a lot of coding. I have an api below to simplify this process and make it elegant

Like this: The Callable event is executed by the child process (jvm)

        JVMLauncher<Integer> launcher = JVMLaunchers.<Integer>newJvm()
                .setCallable(() -> {
                    System.out.println("************ Compile start ***************");
                    TimeUnit.SECONDS.sleep(1);
                    System.out.println("************ Compile stop ***************");
                    return 1;
                })
                .addUserjars(Collections.emptyList())
                .setConsole((msg) -> System.err.println(msg))
                .build();

        VmFuture<Integer> out = launcher.startAndGet();

@sebbASF
Copy link
Copy Markdown
Contributor

sebbASF commented Aug 23, 2018

I think this is getting out of scope for LANG, given that there is already the EXEC component.

@harbby
Copy link
Copy Markdown
Author

harbby commented Aug 23, 2018

@sebbASF I think exec focuses on executing the operating system child process (shell start).
And my api, focusing on the task collaboration with the two jvm,
For example, the parent process hands a temporary compilation job to the child process (jvm) to execute, and waits for it to return the compilation result.

@garydgregory
Copy link
Copy Markdown
Member

It does sound like this is in the Commons Exec domain.

@sebbASF
Copy link
Copy Markdown
Contributor

sebbASF commented Aug 23, 2018

AFAICT the code starts the JVM using an OS process.
It also makes assumptions about the classpath separator character that may not apply to all OSes.

There may be other such assumptions. EXEC should already deal with all of these.

I still think this belongs in EXEC rather than LANG.

It might make a useful enhancement to EXEC?

@harbby
Copy link
Copy Markdown
Author

harbby commented Aug 23, 2018

Well, what you said is right, it really should be returned to the exec domain.
This api wants to quickly pass the lambda to the child process. In order to simplify the cues of exec, it should be very useful in many scenarios.

@harbby
Copy link
Copy Markdown
Author

harbby commented Nov 18, 2018

Hi all, After a long time, we practiced in many projects, we found pr very interesting, I plan to close this discussion, discuss in commons-exec

@harbby harbby closed this Nov 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants