コード例 #1
0
        private void WaitConsumerExecute()
        {
            bool isRunning = true;
            int  createSnapshoThreadsCount = _createSnapshopThreads.Length;

            for (int i = 0; i < createSnapshoThreadsCount; i++)
            {
                _createSnapshopThreadsStat[i] = false;
            }

            var  spinWait = SpinWaitUtils.GetSpinWait();
            long start    = DateTime.UtcNow.ToMillisecondsSinceEpoch();

            while (isRunning)
            {
                spinWait.SpinOnce();
                int doneCount = 0;
                isRunning = false;
                var now = DateTime.UtcNow.ToMillisecondsSinceEpoch();
                if (now - start > 10000)
                {
                    _logger.DebugFormat("while error, enter offline !");
                    break;
                }

                for (int i = 0; i < createSnapshoThreadsCount; i++)
                {
                    var consumerThread = _createSnapshopThreads[i];
                    if (!consumerThread.IsDone() && !_createSnapshopThreadsStat[i])
                    {
                        isRunning = true;
                    }
                    else
                    {
                        if (!_createSnapshopThreadsStat[i])
                        {
                            _createSnapshopThreadsStat[i] = true;
                        }

                        doneCount++;
                    }
                }
            }
        }
コード例 #2
0
        private void MutilExecute()
        {
            var spinWait = SpinWaitUtils.GetSpinWait();
            MutilExecute <int, CreateSnapshotTask> mutilExecute =
                new MutilExecute <int, CreateSnapshotTask>(SharedConfig.CreateSnapshotThreadCount,
                                                           snapshotSendTasks, CreateSendSnapshot);

            mutilExecute.Start();

            try
            {
                SendSnapshotWait.BeginProfile();
                while (!mutilExecute.IsDone())
                {
                    _logger.DebugFormat("SendSnapshot ThreadsRunning;{0}", mutilExecute.ThreadsRunning);
                    spinWait.SpinOnce();
                }
            }
            finally
            {
                SendSnapshotWait.EndProfile();
            }
        }
コード例 #3
0
        private void MutilExecute()
        {
            var spinWait = SpinWaitUtils.GetSpinWait();
            MutilExecute <int, CreateSnapshotParams> mutilExecute =
                new MutilExecute <int, CreateSnapshotParams>(SharedConfig.CreateSnapshotThreadCount,
                                                             _sendSnapshotTasks, CreateSendSnapshot);

            mutilExecute.Start();

            try
            {
                SingletonManager.Get <DurationHelp>().ProfileStart(CustomProfilerStep.SendSnapshotWait);
                while (!mutilExecute.IsDone())
                {
                    _logger.DebugFormat("SendSnapshot ThreadsRunning;{0}", mutilExecute.ThreadsRunning);
                    spinWait.SpinOnce();
                }
            }
            finally
            {
                SingletonManager.Get <DurationHelp>().ProfileEnd(CustomProfilerStep.SendSnapshotWait);
            }
        }