public override int GetHashCode() { unchecked { return(((Id != null ? Id.GetHashCode() : 0) * 397) ^ Dispatched.GetHashCode()); } }
public void Dispatch(string dispathName, Object obj1, Object obj2, Object obj3) { Dispatched d = mFreeDispathers.Count > 0 ? mFreeDispathers.Pop() : new Dispatched(); d.Set(dispathName, obj1, obj2, obj3); dispatchers.Enqueue(d); }
internal void EndDispatch(SwDocument doc) { lock (m_Lock) { m_DocsDispatchQueue.Remove(doc); var index = m_ModelsDispatchQueue.FindIndex(d => m_Comparer.Equals(d, doc.Model)); if (index != -1) { m_ModelsDispatchQueue.RemoveAt(index); } if (doc is SwUnknownDocument) { doc = (SwDocument)(doc as SwUnknownDocument).GetSpecific(); } Dispatched?.Invoke(doc); if (!m_DocsDispatchQueue.Any()) { DispatchAllModels(); } } }
/// <summary> /// As much as I am concerned, the device is 'working' if I have provided you a result to this call. /// If you fail to send over the wire, that's your concern. /// I also don't care about header format, as long as the dependancy from the work generator is there /// I'm happy with it. /// </summary> /// <returns>Null if no work available to be given.</returns> internal RequestedWork?ConsumeNonces(T originator, ulong scanCount) { var devInfo = GetCurrently(originator); RequestedWork cooked; uint? prev = null; lock (devInfo) { var work = genWork(scanCount); if (null == work) { return(null); } var wid = (uint)work.uniq; // We hope to never have 2^32 work dispatch in flight! cooked = new RequestedWork(wid, work.header, work.target.TargD, work.nonceBase); var dispatching = new Dispatched(work, cooked); if (devInfo.dispatched != null) { prev = devInfo.dispatched.provide.wid; } devInfo.Working(dispatching); } lock (crunching) { if (prev.HasValue) { crunching.Remove(prev.Value); } crunching.Add(cooked.wid, devInfo); } return(cooked); }
private void DispatchAllModels() { lock (m_Lock) { foreach (var model in m_ModelsDispatchQueue) { SwDocument doc; switch (model) { case IPartDoc part: doc = new SwPart(part, m_App, m_Logger, true); break; case IAssemblyDoc assm: doc = new SwAssembly(assm, m_App, m_Logger, true); break; case IDrawingDoc drw: doc = new SwDrawing(drw, m_App, m_Logger, true); break; default: throw new NotSupportedException(); } Dispatched?.Invoke(doc); } m_ModelsDispatchQueue.Clear(); } }
public void Dispatch(string dispathName) { Dispatched d = mFreeDispathers.Count > 0 ? mFreeDispathers.Pop() : new Dispatched(); d.Set(dispathName); dispatchers.Enqueue(d); }
public override int GetHashCode() { unchecked { return(((Id?.GetHashCode() ?? 0) * 397) ^ Dispatched.GetHashCode()); } }
public void Dispatcheding() { while (dispatchers.Count > 0) { Dispatched d = dispatchers.Dequeue(); Call(d.dispatchName, d.obj1, d.obj2, d.obj3); mFreeDispathers.Push(d); //将使用过的派发器添加到栈顶 } }
public BackgroundManager(Dispatched dispatched, Undispatched undispatched) { _dispatchedWorker = dispatched; _undispatchedWorker = undispatched; _dispatchedWorker.Incremented += _dispatchedWorker_Incremented; _runningFor = new Timer(_ => Increment(), null, Timeout.Infinite, Timeout.Infinite); }
public void DispatchPending() { while (mDispatched.Count > 0) { Dispatched d = mDispatched.Dequeue(); Call(d.mEventName, d.mArg1, d.mArg2, d.mArg3); mFreeDispatch.Push(d); } }
private void NotifyDispatchedSafe(SwDocument doc) { try { m_Logger.Log($"Dispatched '{doc.Title}'", LoggerMessageSeverity_e.Debug); Dispatched?.Invoke(doc); } catch (Exception ex) { m_Logger.Log($"Unhandled exception while dispatching the document '{doc.Title}'", LoggerMessageSeverity_e.Error); m_Logger.Log(ex); } }
private async Task Dispatch(CommandBase command) { Dispatched?.Invoke(this, new CommandRunnerEvent(command)); if (command.RunOnUiThread) { await _executeUiThreadFunc(async() => await ExecuteOne(command).ConfigureAwait(false)).ConfigureAwait(false); } else { await Task.Run(() => ExecuteOne(command)).ConfigureAwait(false); } }
private void NotifyDispatchedSafe(SwDocument doc) { try { m_Logger.Log($"Dispatched '{doc.Title}'"); Dispatched?.Invoke(doc); } catch (Exception ex) { m_Logger.Log($"Unhandled exception while dispatching the document '{doc.Title}'"); m_Logger.Log(ex); } }
async Task DispatchAgent.Execute(DispatchContext context) { try { ISendEndpoint endpoint = await context.GetSendEndpoint(context.Destination); IPipe<SendContext> messageContext = CreateMessageContext(context); var dispatched = new Dispatched(); await endpoint.Send(dispatched, messageContext); PublishCommandForwardedEvent(context); } catch (Exception ex) { string message = string.Format(CultureInfo.InvariantCulture, "An exception occurred sending message {0} to {1}", string.Join(",", context.DispatchTypes), context.Destination); _log.Error(message, ex); throw new DispatchException(message, ex); } }
async Task DispatchAgent.Execute(DispatchContext context) { try { ISendEndpoint endpoint = await context.GetSendEndpoint(context.Destination); IPipe <SendContext> messageContext = CreateMessageContext(context); var dispatched = new Dispatched(); await endpoint.Send(dispatched, messageContext); PublishCommandForwardedEvent(context); } catch (Exception ex) { string message = string.Format(CultureInfo.InvariantCulture, "An exception occurred sending message {0} to {1}", string.Join(",", context.DispatchTypes), context.Destination); _log.Error(message, ex); throw new DispatchException(message, ex); } }
protected bool Equals(StoredMessage other) { return(string.Equals(Id, other.Id) && Dispatched.Equals(other.Dispatched)); }
public void Dispatch(string eventName, object param1, object param2) { Dispatched d = (mFreeDispatch.Count == 0) ? new Dispatched() : mFreeDispatch.Pop(); mDispatched.Enqueue(d.Set(eventName, param1, param2)); }
void ICommandPatternObserver <TSpec> .OnCommandDispatched(ICommandDispatch <TSpec> dispatch) => Dispatched?.Invoke(dispatch);
public void Dispatch(string eventName) { Dispatched d = (mFreeDispatch.Count == 0) ? new Dispatched() : mFreeDispatch.Pop(); mDispatched.Enqueue(d.Set(eventName)); }
void ICommandPatternObserver.OnCommandDispatched(ICommandDispatch dispatch) => Dispatched?.Invoke((ICommandDispatch <TSpec>)dispatch);
internal void Working(Dispatched work) { lastReceived = DateTime.UtcNow; dispatched = work; }