Hi Kamil, this is a good idea and your code is well written, however in order to really work, a mutex need support from the operating system or from a container, because the instruction for lock and unlock the mutex needs to be atomic. I couldn't see any support from the container (web server), so it will work some times and fail some times.
Kamil Dziedzic - 2013-09-27 10:46:37 - In reply to message 1 from Alfredito
I'm not really sure if I understand your doubts.
Mutex class abstracts the way you gain lock so you don't need to play with low level stuff you need to only use ->acquireLock() and ->releaseLock() methods.
Atomic locking is done by Lock classes and Mutex can use any of them.
Currently you can choose between 5 of them which uses one of the following method: flock, memcache, mysql, redis.
Each of this class uses an atomic, locking mechanism.
Of course each of this method has some pros and cons - and thats why I've build this class so you could always switch between methods without much effort and choose which one suits you best.
You may see some usage examples on github project page https://github.com/arvenil/ninja-mutex which may light things a little better (Can I somehow place here good help docs?).