-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
699e8c1
commit ca67bcd
Showing
34 changed files
with
384 additions
and
377 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
drools-base/src/main/java/org/drools/base/common/PartitionsManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package org.drools.base.common; | ||
|
||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
public class PartitionsManager { | ||
|
||
private static final int MIN_PARALLEL_THRESHOLD = Runtime.getRuntime().availableProcessors(); | ||
private static final int MAX_PARALLEL_THRESHOLD = Runtime.getRuntime().availableProcessors(); | ||
|
||
private final AtomicInteger partitionCounter = new AtomicInteger( 0 ); | ||
|
||
private int parallelEvaluationSlotsCount = -1; | ||
|
||
public RuleBasePartitionId createNewPartitionId() { | ||
return new RuleBasePartitionId(this, partitionCounter.incrementAndGet()); | ||
} | ||
|
||
public int getPartitionsCount() { | ||
return partitionCounter.get(); | ||
} | ||
|
||
public boolean hasParallelEvaluation() { | ||
return getPartitionsCount() >= MIN_PARALLEL_THRESHOLD; | ||
} | ||
|
||
public int getParallelEvaluationSlotsCount() { | ||
return parallelEvaluationSlotsCount; | ||
} | ||
|
||
public void init() { | ||
this.parallelEvaluationSlotsCount = Math.min(getPartitionsCount(), MAX_PARALLEL_THRESHOLD); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.