public object restart(object newState, bool clearActions) { if (getError() == null) { throw new InvalidOperationException("Agent does not need a restart"); } Validate(newState); _state = newState; if (clearActions) { _aq.Set(ActionQueue.EMPTY); } else { bool restarted = false; ActionQueue prior = null; while (!restarted) { prior = _aq.Get(); restarted = _aq.CompareAndSet(prior, new ActionQueue(prior._q, null)); } if (prior._q.count() > 0) { ((Action)prior._q.peek()).execute(); } } return(newState); }
/// <summary> /// Construct a namespace with a given name. /// </summary> /// <param name="name">The name.</param> Namespace(Symbol name) : base(name.meta()) { _name = name; _mappings.Set(RT.DEFAULT_IMPORTS); _aliases.Set(RT.map()); }
public object reset(object newval) { object oldval = _state.Get(); Validate(newval); _state.Set(newval); NotifyWatches(oldval, newval); return(newval); }
/// <summary> /// Set the value. /// </summary> /// <param name="newv">The new value.</param> /// <returns>The new value.</returns> public object reset(object newv) { object oldv = _state.Get(); Validate(newv); _state.Set(newv); notifyWatches(oldv, newv); return(newv); }