Implementation of sleep()

General discussion on Zend Core for IBM System i
Post Reply
jonfparis
Posts: 23
Joined: Thu Apr 09, 2009 9:51 pm

Implementation of sleep()

Post by jonfparis » Thu Apr 09, 2009 9:58 pm

On IBM i the C function sleep() has almost no impact on system performance. From reading other PHP forums it appears that it seems to cause problems with some PHP implementations.

If issue sleep() will it a) Use the underlying C function and therefore have no impact and b) Will it have the effect of "hanging" the thread in question ?

Reason for asking is that I am trying to find a way to have a PHP job running in the background waiting for requests (on a dataqueue or whatever) and serving up responses in a similar manner.


Jon Paris

chris_hird
Posts: 171
Joined: Fri Apr 10, 2009 12:41 am
Location: Toronto
Contact:

Re: Implementation of sleep()

Post by chris_hird » Fri Apr 10, 2009 12:43 am

Jon

Not sure if using the sleep function makes sense when you can always wait on a data queue for a period of time or until it gets a message? I use this extensively for reacting to job queue messages, if I do get a time out I simply check for a stop message in another queue. Not totally sure if this is what you are asking?

Chris...
Shield Advanced Solutions Ltd
Home of JobQGenie and the Receiver Apply Program
http://www.shield.on.ca/Blog

jonfparis
Posts: 23
Joined: Thu Apr 09, 2009 9:51 pm

Re: Implementation of sleep()

Post by jonfparis » Fri Apr 10, 2009 4:42 pm

chris_hird wrote:Jon

Not sure if using the sleep function makes sense when you can always wait on a data queue for a period of time or until it gets a message? I use this extensively for reacting to job queue messages, if I do get a time out I simply check for a stop message in another queue. Not totally sure if this is what you are asking?

Chris...
Since I posted this I have been thinking that tying up a thread wouldn't matter anyway - it won't go through the apache server if you invoke PHP directly in PASE anyway will it?

As to your comment on Qs - do you actually do this with PHP scripts? If so I'd love to see an example. I've used them many times with "regular" apps - but never involving PASE.


Jon

chris_hird
Posts: 171
Joined: Fri Apr 10, 2009 12:41 am
Location: Toronto
Contact:

Re: Implementation of sleep()

Post by chris_hird » Fri Apr 17, 2009 1:47 pm

Jon

No never done it with PHP scripts, thinking about it makes me wonder just what it would do? If the time is longer than the server timeout for the php interpreter would it not simply cause an HTTP error to be returned? This would be the same regardless of the wait process used? The API to Retrieve a Data Queue entry has to be being used under the covers so I cannot see why it should not work the same in terms of coding? I could simply create a C program to do what I need and have the PHP call it if the PHP methods don't support the timeout value? Not checked that out yet???

I am doing more PHP scripting now after a long break due to other projects, so once I get to the Data Queue processes I will give it a try..

Chris...
Shield Advanced Solutions Ltd
Home of JobQGenie and the Receiver Apply Program
http://www.shield.on.ca/Blog

Post Reply