コード例 #1
0
        /// <summary>
        ///     Processes the next available tasks and returns true when it has been processed and false otherwise.
        ///     This method will block until th exitHandle has been set or a task should be processed.
        ///     Only call this inside the thread you want the tasks to process to be processed.
        /// </summary>
        /// <param name="exitHandle">The handle to indicate an early abort of the wait process.</param>
        /// <returns>False when the exitHandle has been set, true otherwise.</returns>
        public bool ProcessNextTask(WaitHandle exitHandle)
        {
            var result = WaitHandle.WaitAny(new [] { exitHandle, DataEvent });

            if (result == 0)
            {
                return(false);
            }

            CustomTask task;

            lock (TaskListSyncRoot)
            {
                if (TaskList.Count == 0)
                {
                    return(false);
                }
                task = TaskList.Dequeue();
            }

            ProcessSingleTask(task);
            if (TaskCount == 0)
            {
                DataEvent.Reset();
            }

            return(true);
        }
コード例 #2
0
ファイル: Dispatcher.cs プロジェクト: Sleaker/UnityVoxelTest
        /// <summary>
        /// Processes the next available tasks and returns true when it has been processed and false otherwise.
        /// This method will block until th exitHandle has been set or a task should be processed.
        /// Only call this inside the thread you want the tasks to process to be processed.
        /// </summary>
        /// <param name="exitHandle">The handle to indicate an early abort of the wait process.</param>
        /// <returns>False when the exitHandle has been set, true otherwise.</returns>
        public bool ProcessNextTask(WaitHandle exitHandle)
        {
            var result = WaitHandle.WaitAny(new[] { exitHandle, DataEvent });

            if (result == 0)
            {
                return(false);
            }

            lock (TaskList)
                ProcessSingleTask();
            if (TaskCount == 0)
            {
                DataEvent.Reset();
            }
            return(true);
        }
コード例 #3
0
ファイル: Dispatcher.cs プロジェクト: Sleaker/UnityVoxelTest
        /// <summary>
        /// Processed the next available task.
        /// Only call this inside the thread you want the tasks to process to be processed.
        /// </summary>
        /// <returns>True when a task to process has been processed, false otherwise.</returns>
        public bool ProcessNextTask()
        {
            lock (TaskList)
            {
                if (TaskList.Count == 0)
                {
                    return(false);
                }
                ProcessSingleTask();
            }

            if (TaskCount == 0)
            {
                DataEvent.Reset();
            }

            return(true);
        }
コード例 #4
0
        private void ProcessTasksInternal()
        {
            List <CustomTask> tmpCopy;

            lock (TaskListSyncRoot)
            {
                tmpCopy = new List <CustomTask>(TaskList);
                TaskList.Clear();
            }

            while (tmpCopy.Count != 0)
            {
                var task = tmpCopy[0];
                tmpCopy.RemoveAt(0);
                ProcessSingleTask(task);
            }

            if (TaskCount == 0)
            {
                DataEvent.Reset();
            }
        }
コード例 #5
0
        /// <summary>
        ///     Processed the next available task.
        ///     Only call this inside the thread you want the tasks to process to be processed.
        /// </summary>
        /// <returns>True when a task to process has been processed, false otherwise.</returns>
        public bool ProcessNextTask()
        {
            CustomTask task;

            lock (TaskListSyncRoot)
            {
                if (TaskList.Count == 0)
                {
                    return(false);
                }
                task = TaskList.Dequeue();
            }

            ProcessSingleTask(task);

            if (TaskCount == 0)
            {
                DataEvent.Reset();
            }

            return(true);
        }
コード例 #6
0
ファイル: Dispatcher.cs プロジェクト: Sleaker/UnityVoxelTest
        private void ProcessTasksInternal()
        {
            lock (TaskList)
            {
                float accum = 0;
                while (TaskList.Count != 0)
                {
                    //If we have taken more than 33ms to run all tasks, return and wait for
                    //the next frame to run more tasks.
                    if (accum >= (1f / FPSTarget))
                    {
                        return;
                    }
                    float s = Time.realtimeSinceStartup;
                    ProcessSingleTask();
                    accum += Time.realtimeSinceStartup - s;
                }
            }

            if (TaskCount == 0)
            {
                DataEvent.Reset();
            }
        }