예제 #1
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(((Id != null ? Id.GetHashCode() : 0) * 397) ^ Dispatched.GetHashCode());
     }
 }
예제 #2
0
        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);
        }
예제 #3
0
        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();
                }
            }
        }
예제 #4
0
파일: Tracker.cs 프로젝트: MaxDZ8/fastdee
        /// <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);
        }
예제 #5
0
        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();
            }
        }
예제 #6
0
        public void Dispatch(string dispathName)
        {
            Dispatched d = mFreeDispathers.Count > 0 ? mFreeDispathers.Pop() : new Dispatched();

            d.Set(dispathName);
            dispatchers.Enqueue(d);
        }
예제 #7
0
 public override int GetHashCode()
 {
     unchecked
     {
         return(((Id?.GetHashCode() ?? 0) * 397) ^ Dispatched.GetHashCode());
     }
 }
예제 #8
0
 public void Dispatcheding()
 {
     while (dispatchers.Count > 0)
     {
         Dispatched d = dispatchers.Dequeue();
         Call(d.dispatchName, d.obj1, d.obj2, d.obj3);
         mFreeDispathers.Push(d);  //将使用过的派发器添加到栈顶
     }
 }
예제 #9
0
        public BackgroundManager(Dispatched dispatched, Undispatched undispatched)
        {
            _dispatchedWorker   = dispatched;
            _undispatchedWorker = undispatched;

            _dispatchedWorker.Incremented += _dispatchedWorker_Incremented;

            _runningFor = new Timer(_ => Increment(), null, Timeout.Infinite, Timeout.Infinite);
        }
예제 #10
0
 public void DispatchPending()
 {
     while (mDispatched.Count > 0)
     {
         Dispatched d = mDispatched.Dequeue();
         Call(d.mEventName, d.mArg1, d.mArg2, d.mArg3);
         mFreeDispatch.Push(d);
     }
 }
예제 #11
0
 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);
     }
 }
예제 #12
0
        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);
            }
        }
예제 #13
0
 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);
            }
        }
예제 #15
0
        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);
            }
        }
예제 #16
0
 protected bool Equals(StoredMessage other)
 {
     return(string.Equals(Id, other.Id) && Dispatched.Equals(other.Dispatched));
 }
예제 #17
0
        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));
        }
예제 #18
0
 void ICommandPatternObserver <TSpec> .OnCommandDispatched(ICommandDispatch <TSpec> dispatch)
 => Dispatched?.Invoke(dispatch);
예제 #19
0
        public void Dispatch(string eventName)
        {
            Dispatched d = (mFreeDispatch.Count == 0) ? new Dispatched() : mFreeDispatch.Pop();

            mDispatched.Enqueue(d.Set(eventName));
        }
예제 #20
0
 void ICommandPatternObserver.OnCommandDispatched(ICommandDispatch dispatch)
 => Dispatched?.Invoke((ICommandDispatch <TSpec>)dispatch);
예제 #21
0
파일: Tracker.cs 프로젝트: MaxDZ8/fastdee
 internal void Working(Dispatched work)
 {
     lastReceived = DateTime.UtcNow;
     dispatched   = work;
 }