Say I have an application recieving concurrent requests. User A and B send requests same time, I need to process requests in a queue.
I need something like this:
function processRequests() {
if(locked()) {
wait();
}
$this->lock();
...process...
$this->unlock();
}
Is there any packages or patterns helping to solve this problem?
PLEASE DON'T OFFER ANY "MESSAGE QUEUE SERVER" SOLUTIONS!
class Requests {private static $locked = false;static function process(){if(self::$locked==true) {/*wait();*/die('locked');//remove it}self::$locked=true;echo '..process...';//self::$locked=false;}}\Requests::process();\Requests::process();