From c9c4a8aa789ed0b2bf95973eebabdb31ac515db5 Mon Sep 17 00:00:00 2001 From: Christopher Vagnetoft Date: Sun, 15 Apr 2018 20:52:49 +0200 Subject: [PATCH] Updated readme --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index c34ac4d..d879bec 100644 --- a/README.md +++ b/README.md @@ -85,8 +85,31 @@ this identifier, and thus point to another segment, just clone it. ### Semaphores +Semaphores are created with a key and a max count. + + $key = new FileKey(__FILE__); + $sem = new Semaphore($key, 2); + + $sem->allocate(); // -> true + $sem->allocate(); // -> true + $sem->allocate(); // -> false + $sem->release(); + + $mutex->destroy(); + ### Mutexes +A mutex is a semaphore with a max count of 1. + + $key = new FileKey(__FILE__); + $mutex = new Mutex($key); + + $mutex->allocate(); // -> true + $mutex->allocate(); // -> false + $mutex->release(); + + $mutex->destroy(); + ### Message Queues $key = new FileKey(__FILE__);