Skip to content

Commit

Permalink
Parallel Startups
Browse files Browse the repository at this point in the history
  • Loading branch information
GedMarc committed Mar 3, 2024
1 parent 40b7c32 commit 03aaf2d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main/java/com/guicedee/guicedinjection/GuiceContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,17 @@ private void loadPostStartups()
{
log.info("Starting Post Startup Group [" + key + "] in Parallel");
ExecutorService postStartup = null;
for (IGuicePostStartup iGuicePostStartup : value)
value.stream().forEach(a->{
try
{
a.postLoad();
}
catch (Throwable T)
{
log.log(Level.SEVERE, "Cannot execute post startup - ", T);
}
});
/*for (IGuicePostStartup iGuicePostStartup : value)
{
postStartup = JobService.INSTANCE.addJob("PostStartup", () -> {
try
Expand All @@ -836,7 +846,7 @@ private void loadPostStartups()
catch (Throwable e)
{
log.log(Level.SEVERE, "Cannot execute post startup - ", e);
}
}*/
}
GuiceContext.log.fine("Completed with Post Startups Key [" + key + "]");
}
Expand Down
18 changes: 18 additions & 0 deletions src/main/java/com/guicedee/guicedinjection/JobService.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,24 @@ public ExecutorService removeJob(String pool)
serviceMap.remove(pool);
return es;
}

/**
* Completes and Removes all jobs running from the given pool
*
* @param pool The pool to remove
*/
public ExecutorService removeJobNoWait(String pool)
{
ExecutorService es = serviceMap.get(pool);
if (es == null)
{
log.warning("Pool " + pool + " was not registered");
return null;
}
waitForJob(pool,1L,TimeUnit.MILLISECONDS);
serviceMap.remove(pool);
return es;
}

/**
* Completes and Removes all jobs running from the given pool
Expand Down

0 comments on commit 03aaf2d

Please sign in to comment.