action repeating

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kavaja
Forum Newbie
Posts: 1
Joined: Fri Feb 11, 2005 2:50 am

action repeating

Post by kavaja »

HI
I need to create server for one game. But for seerver limits iI must use php instead java. I started yesterday with learning and I dont know if and how this could be done in php: Server must be running everytime from time he is deployed on server to shutdown. He must check game state and be performing nescessary actions every 1/10 of second. Like this in java language:

public void run()
{

while(isALive)
{
//prikazy...
Thread.sleep(100);
}

}

How is it with running this infinity script on server? Are with this any problems??

Thanks for answers
Last edited by kavaja on Fri Feb 11, 2005 3:15 am, edited 1 time in total.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

for one, an infinitely running loop will typically eat the processor on the server, although at .1 second loops, it's less of a problem than most.. but, depending on number of actions needed, that can be using a lot of system resources.

the major thing to do is run it from the command line, or via cron.. using a mutex/semaphore locking mechanism to keep from running concurrently.. You'll have to set the script to have an infinite time limit as well.
Post Reply