MCPcopy Index your code
hub / github.com/clojure/clojure / doCommute

Method doCommute

src/jvm/clojure/lang/LockingTransaction.java:467–491  ·  view source on GitHub ↗
(Ref ref, IFn fn, ISeq args)

Source from the content-addressed store, hash-verified

465}
466
467Object doCommute(Ref ref, IFn fn, ISeq args) {
468 if(!info.running())
469 throw retryex;
470 if(!vals.containsKey(ref))
471 {
472 Object val = null;
473 try
474 {
475 ref.lock.readLock().lock();
476 val = ref.tvals == null ? null : ref.tvals.val;
477 }
478 finally
479 {
480 ref.lock.readLock().unlock();
481 }
482 vals.put(ref, val);
483 }
484 ArrayList<CFn> fns = commutes.get(ref);
485 if(fns == null)
486 commutes.put(ref, fns = new ArrayList<CFn>());
487 fns.add(new CFn(fn, args));
488 Object ret = fn.applyTo(RT.cons(vals.get(ref), args));
489 vals.put(ref, ret);
490 return ret;
491}
492
493/*
494//for test

Callers 1

commuteMethod · 0.80

Calls 8

consMethod · 0.95
runningMethod · 0.80
lockMethod · 0.80
containsKeyMethod · 0.65
getMethod · 0.65
addMethod · 0.65
applyToMethod · 0.65
putMethod · 0.45

Tested by

no test coverage detected