public void setValidator(IFn vf){ if(hasRoot()) validate(vf, root); validator = vf; }
public void setValidator(IFn vf){ if(hasRoot()) validate(vf, root); validator = vf; }
synchronized public void commuteRoot(IFn fn) { Object newRoot = fn.invoke(root); validate(getValidator(), newRoot); Object oldroot = root; this.root = newRoot; ++rev; notifyWatches(oldroot,newRoot); }
public Object set(Object val){ validate(getValidator(), val); TBox b = getThreadBinding(); if(b != null) { if(Thread.currentThread() != b.thread) throw new IllegalStateException(String.format("Can't set!: %s from non-binding thread", sym)); return (b.val = val); } throw new IllegalStateException(String.format("Can't change/establish root binding of: %s with set", sym)); }
public Object set(Object val){ validate(getValidator(), val); TBox b = getThreadBinding(); if(b != null) { if(Thread.currentThread() != b.thread) throw new IllegalStateException(String.format("Can't set!: %s from non-binding thread", sym)); return (b.val = val); } throw new IllegalStateException(String.format("Can't change/establish root binding of: %s with set", sym)); }
synchronized void swapRoot(Object root){ validate(getValidator(), root); Object oldroot = this.root; this.root = root; ++rev; notifyWatches(oldroot,root); }
synchronized void swapRoot(Object root){ validate(getValidator(), root); Object oldroot = this.root; this.root = root; ++rev; notifyWatches(oldroot,root); }
synchronized public void bindRoot(Object root){ validate(getValidator(), root); Object oldroot = this.root; this.root = root; ++rev; try { alterMeta(dissoc, RT.list(macroKey)); } catch (Exception e) { throw Util.sneakyThrow(e); } notifyWatches(oldroot,this.root); }
synchronized public void commuteRoot(IFn fn) { Object newRoot = fn.invoke(root); validate(getValidator(), newRoot); Object oldroot = root; this.root = newRoot; ++rev; notifyWatches(oldroot,newRoot); }
public static void pushThreadBindings(Associative bindings){ Frame f = dvals.get(); Associative bmap = f.bindings; for(ISeq bs = bindings.seq(); bs != null; bs = bs.next()) { IMapEntry e = (IMapEntry) bs.first(); Var v = (Var) e.key(); if(!v.dynamic) throw new IllegalStateException(String.format("Can't dynamically bind non-dynamic var: %s/%s", v.ns, v.sym)); v.validate(v.getValidator(), e.val()); v.threadBound.set(true); bmap = bmap.assoc(v, new TBox(Thread.currentThread(), e.val())); } dvals.set(new Frame(bmap, f)); }
synchronized public void bindRoot(Object root){ validate(getValidator(), root); Object oldroot = this.root; this.root = root; ++rev; alterMeta(dissoc, RT.list(macroKey)); notifyWatches(oldroot,this.root); }
synchronized public Object alterRoot(IFn fn, ISeq args) { Object newRoot = fn.applyTo(RT.cons(root, args)); validate(getValidator(), newRoot); Object oldroot = root; this.root = newRoot; ++rev; notifyWatches(oldroot,newRoot); return newRoot; }