Skip to content

Commit

Permalink
Feature: Allow multi-threading in sub tasks #137
Browse files Browse the repository at this point in the history
  • Loading branch information
SonarSonic committed Apr 18, 2024
1 parent abda187 commit 55044bb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/main/java/drawingbot/plotting/PFMTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public class PFMTask extends DBTask<PlottedDrawing> implements ISpecialListenabl
public boolean finishEarly = false;
public PlottingTools tools;
public boolean isSubTask = false;
public boolean allowSubTaskMultiThreading = false;

// RENDERING \\\
public boolean skipReRender = false;
Expand Down Expand Up @@ -427,6 +428,14 @@ public boolean isSubTask() {
return isSubTask;
}

public boolean allowSubTaskMultiThreading(){
return allowSubTaskMultiThreading;
}

public boolean canUseMultiThreading(){
return !isSubTask() || allowSubTaskMultiThreading();
}

//// RENDERING \\\\

private WrappedGeometryIterator iterator;
Expand Down
7 changes: 7 additions & 0 deletions src/main/java/drawingbot/plotting/PFMTaskBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class PFMTaskBuilder {

/** If the tasks lifecycle is controlled by another task */
public boolean isSubTask;
public boolean allowSubTaskMultiThreading;

/** Set to true if you wish to bypass any external custom task suppliers / setup, e.g. if using a PFM inside another PFM and not in an external task this should be set to true */
public boolean useInternalBuilder;
Expand Down Expand Up @@ -111,6 +112,7 @@ public PFMTask createPFMTask(){
}

task.isSubTask = isSubTask;
task.allowSubTaskMultiThreading = allowSubTaskMultiThreading;

if(postSetup != null){
postSetup.accept(task);
Expand Down Expand Up @@ -173,6 +175,11 @@ public PFMTaskBuilder setSubTask(boolean isSubTask) {
return this;
}

public PFMTaskBuilder setAllowSubTaskMultiThreading(boolean allowSubTaskMultiThreading) {
this.allowSubTaskMultiThreading = allowSubTaskMultiThreading;
return this;
}

public PFMTaskBuilder setUseInternalBuilder(boolean useInternalBuilder) {
this.useInternalBuilder = useInternalBuilder;
return this;
Expand Down

0 comments on commit 55044bb

Please sign in to comment.