Permalink
Browse files

Make ETask.reds private

  • Loading branch information...
1 parent 7393f37 commit 5633e63037dfe23009fa82e7c93d1f616b0d9655 @esstrifork esstrifork committed Jan 29, 2014
@@ -446,7 +446,7 @@ public EObject process_info(EObject spec) {
ERT.box(0));
} else if (spec == am_reductions) {
- return new ETuple2(am_reductions, ERT.box(this.reds));
+ return new ETuple2(am_reductions, ERT.box(this.get_reductions()));
} else if (spec == am_initial_call) {
return new ETuple2(am_initial_call,
@@ -29,7 +29,6 @@
import java.math.BigInteger;
import java.nio.ByteBuffer;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -603,11 +602,8 @@ private static boolean send_to_locally_registered(EProc proc, EAtom name, EObjec
}
private static void send_to_handle(EProc proc, EHandle handle, EObject msg) throws Pausable {
- proc.reds += handle.send(proc.self_handle(), msg);
- if (proc.reds > 1000) {
- proc.reds = 0;
- Task.yield();
- }
+ int penalty = handle.send(proc.self_handle(), msg);
+ proc.bump_reductions(penalty);
}
/**
@@ -32,6 +32,7 @@
import com.trifork.clj_ds.IPersistentSet;
import com.trifork.clj_ds.PersistentHashSet;
+import kilim.Task;
/**
* An ETask is what is common for processes and open ports
@@ -260,7 +261,8 @@ public EObject get_monitored_object(ERef monitor) {
protected volatile STATE pstate = STATE.INIT;
protected EObject exit_reason;
- public int reds;
+ /** Reduction counter. */
+ private int reds;
protected Throwable killer;
@@ -297,6 +299,17 @@ public void mbox_remove_one() throws Pausable {
mbox.get();
}
+ public int get_reductions() { return reds;}
+
+ public void bump_reductions(int amount) throws Pausable {
+ reds += amount;
+ if (reds > 1000) {
+ reds = 0;
+ Task.yield();
+ }
+
+ }
+
/**
* @param from
* @param reason
@@ -761,7 +761,7 @@ static public EObject statistics(EProc proc, EObject spec) {
return ETuple.make(ERT.box(since_epoch), ERT.box(since_last));
} else if (spec == am_reductions) {
- long current_reds = proc.reds;
+ long current_reds = proc.get_reductions();
long since_last = current_reds - last_reductions;
last_reductions = current_reds;
@@ -771,7 +771,7 @@ static public EObject statistics(EProc proc, EObject spec) {
long current_reds = 0L;
for (EProc p : EProc.all_tasks.values()) {
- current_reds += p.reds;
+ current_reds += p.get_reductions();
}
long since_last = current_reds - last_exact_reductions;
last_exact_reductions = current_reds;

0 comments on commit 5633e63

Please sign in to comment.