Example #1
0
        public MultiThreadRunner(string name, bool relaxed = true)
        {
#if !NETFX_CORE || NET_STANDARD_2_0 || NETSTANDARD2_0
            var thread = new Thread(() =>
            {
                _name = name;

                RunCoroutineFiber();
            });

            thread.IsBackground = true;
            if (relaxed)
            {
                _lockingMechanism = RelaxedLockingMechanism;
            }
            else
            {
                _lockingMechanism = QuickLockingMechanism;
            }
#else
            var thread = new Task(() =>
            {
                _name = name;

                RunCoroutineFiber();
            });

            _lockingMechanism = RelaxedLockingMechanism;
#endif

            _mevent = new ManualResetEventEx();

            thread.Start();
        }
Example #2
0
            public RunnerData(bool relaxed, float interval, string name, bool isRunningTightTasks,
                              TFlowModifier modifier)
            {
                _mevent              = new ManualResetEventEx();
                _watch               = new Stopwatch();
                _coroutines          = new FasterList <TTask>();
                newTaskRoutines      = new ThreadSafeQueue <TTask>();
                _interval            = (long)(interval * 10000);
                this.name            = name;
                _isRunningTightTasks = isRunningTightTasks;
                _flushingOperation   = new CoroutineRunner <TTask> .FlushingOperation();

                modifier.runnerName = name;
                _process            = new CoroutineRunner <TTask> .Process <TFlowModifier>
                                          (newTaskRoutines, _coroutines, _flushingOperation, modifier);

                if (relaxed)
                {
                    _lockingMechanism = RelaxedLockingMechanism;
                }
                else
                {
                    _lockingMechanism = QuickLockingMechanism;
                }
            }
 public RunnerData(bool relaxed, int interval, string name)
 {
     _mevent          = new ManualResetEventEx();
     _relaxed         = relaxed;
     _watch           = new Stopwatch();
     _coroutines      = new FasterList <IPausableTask>();
     _newTaskRoutines = new ThreadSafeQueue <IPausableTask>();
     _interval        = interval;
     _name            = name;
 }
Example #4
0
 public RunnerData(bool relaxed, float interval, string name, bool isRunningTightTasks)
 {
     _mevent              = new ManualResetEventEx();
     _relaxed             = relaxed;
     _watch               = new Stopwatch();
     _coroutines          = new FasterList <IPausableTask>();
     _newTaskRoutines     = new ThreadSafeQueue <IPausableTask>();
     _interval            = (long)(interval * 10000);
     _name                = name;
     _isRunningTightTasks = isRunningTightTasks;
 }
Example #5
0
            public RunnerData(bool relaxed, float interval, string name, bool isRunningTightTasks)
            {
                _mevent              = new ManualResetEventEx();
                _watch               = new Stopwatch();
                _coroutines          = new FasterList <ISveltoTask <T> >();
                newTaskRoutines      = new ThreadSafeQueue <ISveltoTask <T> >();
                _intervalInTicks     = (long)(interval * Stopwatch.Frequency / 1000);
                this.name            = name;
                _isRunningTightTasks = isRunningTightTasks;

                if (relaxed)
                {
                    _lockingMechanism = RelaxedLockingMechanism;
                }
                else
                {
                    _lockingMechanism = QuickLockingMechanism;
                }
            }
Example #6
0
            public RunnerData(bool relaxed, float interval, string name, bool isRunningTightTasks)
            {
                _mevent              = new ManualResetEventEx();
                _watch               = new Stopwatch();
                _coroutines          = new FasterList <IPausableTask>();
                _newTaskRoutines     = new ThreadSafeQueue <IPausableTask>();
                _interval            = (long)(interval * 10000);
                _name                = name;
                _isRunningTightTasks = isRunningTightTasks;

                if (relaxed)
                {
                    LockingMechanism = RelaxedLockingMechanism;
                }
                else
                {
                    LockingMechanism = QuickLockingMechanism;
                }
            }
Example #7
0
        public MultiThreadRunner(string name, bool relaxed = true)
        {
            _mevent = new ManualResetEventEx();

            if (relaxed)
            {
                _lockingMechanism = RelaxedLockingMechanism;
            }
            else
            {
                _lockingMechanism = QuickLockingMechanism;
            }

#if !NETFX_CORE || NET_STANDARD_2_0 || NETSTANDARD2_0
            //threadpool doesn't work well with Unity apparently
            //it seems to choke when too meany threads are started
            var thread = new Thread(() =>
            {
                _name = name;

                RunCoroutineFiber();
            });

            thread.IsBackground = true;

            thread.Start();
#else
            var thread = new Task(() =>
            {
                _name = name;

                RunCoroutineFiber();
            }, TaskCreationOptions.LongRunning);

            thread.Start();
#endif
        }