Skip to content

MrIvanPlays/Process

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Process

A library for running processes in parallel

Docs available here

Code example

ProcessScheduler scheduler = new ProcessScheduler();
scheduler
    .runProcesses(
        Process.fromRunnable(
            () -> {
              try {
                Thread.sleep(20);
              } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
              }
              System.out.println("foo");
            }),
        Process.fromRunnable(() -> System.out.println("bar")),
        Process.fromRunnable(() -> System.out.println("lorem ipsum dolor sit amet")))
    .whenDoneAsync(
        errors -> {
          if (!errors.isEmpty()) {
            System.out.println("done with errors");
            for (ProcessException e : errors) {
              e.printStackTrace();
            }
            return;
          }
          System.out.println("done");
        });

How To (Maven)

<build>
  <plugins>
    <plugin>
      <version>3.7.0</version>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <configuration>
        <source>1.8</source>
        <target>1.8</target>
        <compilerArgs>
          <arg>-parameters</arg>
        </compilerArgs>
      </configuration>
    </plugin>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-shade-plugin</artifactId>
      <version>3.1.1</version>
      <configuration>
        <relocations>
          <!-- Relocating is only necessary if you're shading for other library addition -->
          <relocation>
            <pattern>com.mrivanplays.process</pattern>
            <shadedPattern>[YOUR PLUGIN PACKAGE].process</shadedPattern> <!-- Replace this -->
          </relocation>
        </relocations>
      </configuration>
      <executions>
        <execution>
          <phase>package</phase>
          <goals>
            <goal>shade</goal>
          </goals>
        </execution>
      </executions>
    </plugin>
  </plugins>
</build>

<repositories>
  <repository>
    <id>ivan</id>
    <url>https://repo.mrivanplays.com/repository/ivan/</url>
  </repository>
</repositories>

<dependencies>
  <dependency>
    <groupId>com.mrivanplays</groupId>
    <artifactId>process-api</artifactId>
    <version>VERSION</version> <!-- Replace with latest version -->
    <scope>compile</scope>
  </dependency>
</dependencies>

About

A library for running processes in parallel

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages