Recently in the making of a thing, written in Python, WSGI interface, deployed in SAE, the SAE server should be nginx. Of course, the solution is not necessarily python, PHP can, but do not tell me to implement a server, now is Nginx, nginx ....
This is the case: there are two concurrent requests, which are recorded as a and b, and two threads for the server. A executes to half, blocks until B sends a signal to a, and a continues to execute.
There seems to be a pretty straightforward way to do this: Set a Boolean in the cache or database as a mutex. But when I block it, I need to constantly poll the database, which consumes too much resources. So I thought, there is no way to get the curve to the national salvation, to call the system (the system is probably Linux, that is pthread) mutex API it. If two requests the same process, then you may be able to save the address of the mutex to the database ... Well, I'm probably thinking a lot.
Do not use the dead loop (even +sleep) to poll, I would like anything.
Reply content:
Recently in the making of a thing, written in Python, WSGI interface, deployed in SAE, the SAE server should be nginx. Of course, the solution is not necessarily python, PHP can, but do not tell me to implement a server, now is Nginx, nginx ....
This is the case: there are two concurrent requests, which are recorded as a and b, and two threads for the server. A executes to half, blocks until B sends a signal to a, and a continues to execute.
There seems to be a pretty straightforward way to do this: Set a Boolean in the cache or database as a mutex. But when I block it, I need to constantly poll the database, which consumes too much resources. So I thought, there is no way to get the curve to the national salvation, to call the system (the system is probably Linux, that is pthread) mutex API it. If two requests the same process, then you may be able to save the address of the mutex to the database ... Well, I'm probably thinking a lot.
Do not use the dead loop (even +sleep) to poll, I would like anything.
Can I use Named pipes?
Check out the PHP official documentation Process Control extension Posix_kill is it possible?
=_=! Not too understand the meaning of the main, it may be said a and B run, a run to half do not run and then wait for B's notice to execute, is this the meaning?
If that's the point, I think you can split a into a ' and C ', a ' to accept the code before the B notification, C to accept the code after the B notification. A ' and B have finished executing and jump to C to execute the code. C code first to detect whether a ' and B processing content is complete, incomplete will stop running. Of course, the data processed is best stored with external storage. I think this should be the simplest way to implement it.
In addition, if it is SAE, do not do what he thought, the limit of the super-is not likely to let you touch the system-level interface and so on.