private void CleanUpIfClosed(uint target_handle, object key) { if (target_handle < 1) { throw new ArgumentException("target_handle should be > 0"); } else if (key == null) { throw new ArgumentNullException("key"); } Contact contact = Connection.Roster.GetContact(target_handle); DispatchManager dm = contact.DispatchManager; Dispatchable d = dm.Get(contact, key, DispatchObject); if (d != null) { if (d.IsClosed) { dm.Remove(contact, key, DispatchObject); } else { throw new InvalidOperationException(String.Format("{0} already has dispatchable object type {1} with key {2}", contact.Name, DispatchObject.FullName, key) ); } } }
public void Notify(Dispatchable msg) { //Insert the message to the message queue _messagesQueue.Enqueue(msg); //Signal the waiting object _notifyEvent.Set(); }
public void Dispatch(Dispatchable dispatchable) { if (_processDispatch.Get()) { var dispatchId = dispatchable.Id; _access.WriteUsing("dispatched", dispatchId, new Dispatch(dispatchable.TypedState <TextState>(), dispatchable.Entries)); } }
public void Unlock(Dispatchable dispatchable) { if (m_State && m_Active == dispatchable) { m_State = false; m_Active = null; } }
private void OnDispatched(Dispatchable d, EventArgs args) { var handler = Dispatched; if (handler != null) { handler(d, args); } }
private void Dispatch(string streamName, int streamVersion, IEnumerable <TEntry> entries, TState?snapshot) { var dispatchableEntries = entries as TEntry[] ?? entries.ToArray(); var id = GetDispatchId(streamName, streamVersion, dispatchableEntries); var dispatchable = new Dispatchable <TEntry, TState>(id, DateTimeOffset.Now, snapshot, dispatchableEntries); _dispatchables.Add(dispatchable); _dispatcher.Dispatch(dispatchable); }
public void Dispatch(Dispatchable dispatchable) { _dispatchAttemptCount++; if (_processDispatch.Get()) { var dispatchId = dispatchable.Id; _access.WriteUsing("dispatched", dispatchable); _control.ConfirmDispatched(dispatchId, _confirmDispatchedResultInterest); } }
public void Dispatch(Dispatchable <TEntry, TState> dispatchable) { _dispatchAttemptCount++; if (_processDispatch.Get()) { var dispatchId = dispatchable.Id; _access.WriteUsing("dispatched", dispatchId, new DispatchInternal(dispatchable.TypedState <TState>(), dispatchable.Entries)); _control.ConfirmDispatched(dispatchId, _confirmDispatchedResultInterest); } }
public void Remove(Dispatchable Job) { lock (DispatchQueue.SyncRoot) { var array = DispatchQueue.ToArray(); var list = new ArrayList(array); list.Remove(Job); DispatchQueue = new Queue(list); } }
public void Register(float priority, Dispatchable dispatchable) { List <Dispatchable> dispatchables; if (!m_Dispatchables.TryGetValue(priority, out dispatchables)) { dispatchables = new List <Dispatchable>(); m_Dispatchables[priority] = dispatchables; } dispatchables.Add(dispatchable); }
private void ValidateDispatchedState(Person persistedObject, Dispatchable <ObjectEntry <Test1Source>, State <string> > dispatched) { Assert.NotNull(dispatched); Assert.NotNull(dispatched.Id); Assert.NotNull(dispatched.State.Get()); var state = dispatched.TypedState <State <string> >(); Assert.Equal(persistedObject.PersistenceId.ToString(), state.Id); Assert.Equal(persistedObject.GetType().AssemblyQualifiedName, state.Type); Assert.Equal(Metadata.NullMetadata(), state.Metadata); }
public void Append(Dispatchable Job, object Parameter, int Repeats, bool Wait) { JobItem NewJob = new JobItem(); NewJob.Repeats = Repeats; NewJob.Wait = Wait; NewJob.Job = Job; NewJob.Parameter = Parameter; lock (DispatchQueue.SyncRoot) { DispatchQueue.Enqueue(NewJob); } }
internal void Add(Contact contact, object key, Dispatchable d, bool replace) { if (contact == null) { throw new ArgumentNullException("contact"); } else if (key == null) { throw new ArgumentNullException("key"); } else if (d == null) { throw new ArgumentNullException("d"); } else if (!conn.Equals(contact.Connection)) { throw new InvalidOperationException(String.Format("Contact does not belong to connection {0}", conn.AccountId)); } string type = d.GetType().FullName; //Hyena.Log.DebugFormat ("DispatchManager.Add dispatchable type {0}", type); lock (dispatchables) { if (!dispatchables.ContainsKey(contact)) { dispatchables.Add(contact, new Dictionary <string, IDictionary <object, Dispatchable> > ()); } if (!dispatchables[contact].ContainsKey(type)) { dispatchables[contact].Add(type, new Dictionary <object, Dispatchable> ()); } if (!dispatchables[contact][type].ContainsKey(key)) { dispatchables[contact][type].Add(key, d); } else if (replace) { Remove(contact, key, d.GetType()); Add(contact, key, d, false); } else { throw new InvalidOperationException("Dispatchable could not be added to dispatch manager."); } OnDispatched(d, EventArgs.Empty); d.Initialize(); } }
public override void Dispatch(Dispatchable dispatchable) { dispatchable.State.IfPresent(state => { if (HasProjectionsFor(state.Metadata.Operation)) { Dispatch(dispatchable.Id, new BinaryProjectable(state, dispatchable.Entries, dispatchable.Id)); } }); var entries = dispatchable.Entries.Where(entry => HasProjectionsFor(entry.TypeName)).ToList(); if (entries.Any()) { Dispatch(dispatchable.Id, new BinaryProjectable(dispatchable.State.OrElse(null !), entries, dispatchable.Id)); } }
public bool Lock(Dispatchable dispatchable) { if (!m_State) { m_State = true; m_Active = dispatchable; return(true); } else { bool yield = m_Active.Yield(dispatchable); if (yield) { Yield(dispatchable); } return(yield); } }
/// <inheritdoc /> public void PersistDispatchable(Dispatchable <TEntry, TState> dispatchable) => _dispatchables.Add(dispatchable);
/// <inheritdoc /> public void PersistDispatchable(Dispatchable dispatchable) => _dispatchables.Add(dispatchable);
/// <summary> /// Add an item to be dispatched. The item is added to /// the external dispatch queue. /// </summary> /// <param name="dispatchable">to execute later</param> public void AddExternal(Dispatchable dispatchable) { _threadDispatchQueue .GetOrCreate() .Enqueue(dispatchable); }
public void Dispatch(Dispatchable dispatchable) => _control?.ConfirmDispatched(dispatchable.Id, this);
private void Dispatch(Dispatchable <TEntry, TState> dispatchable) => _dispatcher.Dispatch(dispatchable);
public void Dispatch(Dispatchable dispatchable) { }
public void Dispatch(Dispatchable dispatchable) { dispatchableQueue.Enqueue(dispatchable); StartDispatchLoop(); }
internal void Add(Contact contact, object key, Dispatchable d) { Add(contact, key, d, true); }
public void AddExternal(Dispatchable dispatchable) { ArrayDeque<Dispatchable> dispatchQueue = dispatchStateThreadLocal.GetOrCreate(); AddToQueue(dispatchable, dispatchQueue); }
private static void AddToQueue( Dispatchable dispatchable, ICollection<Dispatchable> dispatchQueue) { dispatchQueue.Add(dispatchable); }
public void Dispatch(Dispatchable dispatchable) => _access.WriteUsing("appendedAll", dispatchable.Entries);
private void Dispatch(Dispatchable dispatchable) => _dispatcher.Dispatch(dispatchable);
public virtual bool Yield(Dispatchable dispatchable) { return(false); }
private void Yield(Dispatchable dispatchable) { m_Active = dispatchable; }
public abstract void Dispatch(Dispatchable dispatchable);