I'm new to PHP, so to get started I've decided to implement a singleton.
While I am able to recreate the singleton pattern in php, but I am not sure how to implement double-checked locking.
Is that even possible/needed in PHP. I have read somewhere that PHP is not multithreaded? Can someone confirm that?
If it is multithreaded, can someone explain to me how lock() or synchronize() work in PHP?
Thanks, Henry
Share-nothing Architecture
double-checked locking
In general the database layer is responsible for this. MySQL(innodb) standard has for example row level locking(which should be sufficient for this).
If this is not sufficient than SQL also has for example transactions to make this happen.
Fork processes
Like the slides say PHP has a Share-nothing-Architecture(traditional) which also does imply that PHP does NOT have a thread(model). Although you can compile(not enabled by default) PHP to have support to fork processes which can communicate with each other. When you also compile the Semaphore Functions then you can do things like sem_acquire and sem_release. But in general this does not apply PHP.