/** * Adds a {@link WorkUnit} to this queue, along with an associated weight for that WorkUnit. */ public void addWorkUnit(WorkUnit workUnit, long weight) { WeightedMultiWorkUnit weightMultiWorkUnit; if (this.numMultiWorkUnits < this.maxMultiWorkUnits) { weightMultiWorkUnit = new WeightedMultiWorkUnit(); this.numMultiWorkUnits++; } else { weightMultiWorkUnit = this.weightedWorkUnitQueue.poll(); } weightMultiWorkUnit.addWorkUnit(weight, workUnit); this.weightedWorkUnitQueue.offer(weightMultiWorkUnit); }
/** * Adds a {@link WorkUnit} to this queue, along with an associated weight for that WorkUnit. */ public void addWorkUnit(WorkUnit workUnit, long weight) { WeightedMultiWorkUnit weightMultiWorkUnit; if (this.numMultiWorkUnits < this.maxMultiWorkUnits) { weightMultiWorkUnit = new WeightedMultiWorkUnit(); this.numMultiWorkUnits++; } else { weightMultiWorkUnit = this.weightedWorkUnitQueue.poll(); } weightMultiWorkUnit.addWorkUnit(weight, workUnit); this.weightedWorkUnitQueue.offer(weightMultiWorkUnit); }
/** * Compare with the other weightedMultiWorkUnit based on weight. */ @Override public int compareTo(WeightedMultiWorkUnit weightedMultiWorkUnit) { return Longs.compare(this.weight, weightedMultiWorkUnit.getWeight()); }
/** * Add a new single workUnit to the current workUnits list. Update the weight by adding the weight of the new workUnit. * * @param weight the weight of the newWorkUnit. * @param newWorkUnit the new work unit. */ private void addWorkUnit(long weight, WorkUnit newWorkUnit) { this.addWorkUnit(newWorkUnit); this.weight += weight; }
@Override public boolean equals(Object obj) { if (!(obj instanceof WeightedMultiWorkUnit)) { return false; } WeightedMultiWorkUnit weightedMultiWorkUnit = (WeightedMultiWorkUnit) obj; return this.weight == weightedMultiWorkUnit.getWeight(); }
/** * Compare with the other weightedMultiWorkUnit based on weight. */ @Override public int compareTo(WeightedMultiWorkUnit weightedMultiWorkUnit) { return Longs.compare(this.weight, weightedMultiWorkUnit.getWeight()); }
/** * Add a new single workUnit to the current workUnits list. Update the weight by adding the weight of the new workUnit. * * @param weight the weight of the newWorkUnit. * @param newWorkUnit the new work unit. */ private void addWorkUnit(long weight, WorkUnit newWorkUnit) { this.addWorkUnit(newWorkUnit); this.weight += weight; }
@Override public boolean equals(Object obj) { if (!(obj instanceof WeightedMultiWorkUnit)) { return false; } WeightedMultiWorkUnit weightedMultiWorkUnit = (WeightedMultiWorkUnit) obj; return this.weight == weightedMultiWorkUnit.getWeight(); }