You typically only create a single ThreadPoolComponent in your application, and let all your threaded tasks run within this component. This allows for ideal thread balancing. If you have multiple components, they will not know how to share the CPU between them fairly.
Inheritance: Microsoft.Xna.Framework.GameComponent
Example #1
0
        /// <summary>
        /// Wait will wait for the given task to complete, and then dispose
        /// the context. After Wait() returns, you should do nothing else to
        /// the context.
        /// </summary>
        public void Wait()
        {
            if (Worker == null)
            {
                throw new ObjectDisposedException("TaskContext.Wait()");
            }

            Worker = null;
            Event.WaitOne();
            ThreadPoolComponent.Reclaim(this);
        }
Example #2
0
        public void Dispose()
        {
            if (Worker == null)
            {
                throw new ObjectDisposedException("TaskContext.Dispose()");
            }

            Worker.Context = null;
            Worker         = null;
            ThreadPoolComponent.Reclaim(this);
        }
Example #3
0
 internal TaskContext(ThreadPoolComponent tpc)
 {
     pool_ = tpc;
 }
Example #4
0
 internal TaskContext(ThreadPoolComponent tpc)
 {
     pool_ = tpc;
 }
Example #5
0
        public Shorewood()
        {
            graphics = new GraphicsDeviceManager(this);
            threadPool = new ThreadPoolComponent(this);
            inputHandler = new InputHandler(this);
            inputHandler.AddEvent(Buttons.Back, new EventHandler<ButtonFireEventArgs>(OnPause));
            inputHandler.AddEvent(Buttons.Start, new EventHandler<ButtonFireEventArgs>(OnPause));
            storageScreen = new StorageScreen(this);

            foundWordAnimator = new FoundWordAnimationRenderer(this);
            constantBackground = new ConstantBackground(this);
            fluidSolver = new FluidSolverComponent(this);
            scoreBox = new ScoreBox(this);
            particleSystem = new UniversalParticleSystem(this);
            constantBackground.Enabled = false;
            constantBackground.Visible = false;

            foundWordAnimator.Enabled = false;
            foundWordAnimator.Visible = false;
            graphics.PreferredBackBufferWidth = PlatformDisplaySettings.width;
            graphics.PreferredBackBufferHeight = PlatformDisplaySettings.height;
            fluidSolver.Differences = new Vector2(graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
            IsFixedTimeStep = false;

            Shorewood.Content = base.Content;
            Content.RootDirectory = "Content";
            scale = graphics.PreferredBackBufferHeight / 1000.0f;
            soundTrack = new SoundTrack(this);
            ninthPlanetGames = new NinthPlanetGames.SplashScreen(this);

            ninthPlanetGames.Visible = true;
            ninthPlanetGames.Enabled = true;

            bloom = new BloomComponent(this);

            loadingPosition = (new Vector2(PlatformDisplaySettings.width / 2, PlatformDisplaySettings.height / 2));
            graphics.PreparingDeviceSettings += OnPreparingDeviceSettings;
            ShorewoodPool.InitalizePools();
            physicsEngine = new PhysicsSimulator(new Vector2(0, 100));

            #if XBOX
            services = new GamerServicesComponent(this);
            Components.Add(services);
            #endif

            Components.Add(threadPool);
            storage = new StorageHandler();
            Components.Add(inputHandler);
            Components.Add(storage.sharedSaveDevice);
            Components.Add(soundTrack);
            Components.Add(fluidSolver);
            Components.Add(ninthPlanetGames);
            avatar2DAnimation = new Avatar2DAnimation(this);
            Components.Add(avatar2DAnimation);
            //Components.Add(ietGames);
        }