Example #1
0
        private void run_small_work_forever()
        {
            List <MatchDeclWork> reused_requeued_match_decls = new List <MatchDeclWork>();
            CyclicTimer          timer = new CyclicTimer(STEP);

            for (; ;)
            {
                if (timer.IsBehind())
                {
                    //TODO: Log once every 10 minutes
                }
                timer.WaitUntilNextFrame();

                //Remove to old queues
                {
                    MatchDeclWork work;
                    while (match_decls_in_flux.TryDequeue(out work))
                    {
                        if (!work.match_decl.AllHasAccepted())
                        {
                            var delta = DateTime.Now - work.added;
                            if (delta.TotalSeconds > QUEUE_POP_TIMEOUT)
                            {
                                work.match_decl.TimeOut();
                            }
                            else
                            {
                                reused_requeued_match_decls.Add(work);
                            }
                        }
                    }

                    foreach (var requeued_work in reused_requeued_match_decls)
                    {
                        match_decls_in_flux.Enqueue(requeued_work);
                    }
                    reused_requeued_match_decls.Clear();
                }


                //Run the match finders
                if (match_finders != null)
                {
                    foreach (var f in match_finders)
                    {
                        f.Run();
                    }
                }
            }
        }
Example #2
0
        private void run_all_physics()
        {
            CyclicTimer physics_timer = new CyclicTimer(STEP);
            CyclicTimer network_timer = new CyclicTimer(NETWORK_STEP);

            for (;;)
            {
                physics_timer.WaitUntilNextFrame();
                step_all((float)STEP, network_timer.HasPassedLastFrame());
                if (physics_timer.IsBehind())
                {
                    //TODO: Log once
                }
            }
        }