Wednesday, 12 April 2017

How to use Nodejs multi CPU cores for multi process?

I have CPU 4 cores and I have some code like this:

setInterval(function() {
   Player.RunUpdate();
   Animal.RunUpdate();
   Bullet.RunUpdate();
   GameItems.RunUpdate();
}, 1E3 / FPS);

With each .RunUpdate() is loop like this:

for(var id in player_list){
   //check something and update postion
}

How I can use one core for one .RunUpdate()? Is it possible? Ex:

setInterval(function() {
  core_1{
     Player.RunUpdate();
  }
  core_2{
     Animal.RunUpdate();
  }
  core_3{
     Bullet.RunUpdate();
  }
  core_4{
     GameItems.RunUpdate();
}, 1E3 / FPS);

Thanks for reading!



via Omega P

No comments:

Post a Comment