Updated readme again

This commit is contained in:
Chris 2018-04-15 18:39:10 +02:00
parent 2652480c5d
commit 4e8ab73a88

View File

@ -48,11 +48,12 @@ Traps are used in the main loop to break on signals
// ... // ...
} }
## Timers ### Timers
Timers fire asynchronously at fixed 1 second intervals. It requires signals to be Timers fire asynchronously at fixed 1 second intervals. It requires signals to be
processed; see above. processed; see above.
// Once every second...
$timer = new Timer(function () { $timer = new Timer(function () {
echo "."; echo ".";
}); });
@ -72,11 +73,53 @@ if (!$lock->acquire()) {
## SysV wrappers ## SysV wrappers
All these wrappers depend on a `KeyInterface` being passed to the constructor.
This is usually an instance of a `FileKey`, created as such:
$key = new FileKey(__FILE__);
The key has a project identifier that starts at `chr(0)`, or `"\0"`. To increase
this identifier, and thus point to another segment, just clone it.
$key2 = clone $key1;
### Semaphores ### Semaphores
### Mutexes ### Mutexes
### Messagae Queues ### Message Queues
$key = new FileKey(__FILE__);
$msgq = new Queue($key);
$msgq->send(1, [ "Some data", [ "format"=>"foo" ]]);
$data = $msgq->receive(1, $type);
$msgq->destroy();
### Shared Memory
Shared memory using `SharedData` supports integrity checking when setting, using
the third parameter to `set()`.
$key = new FileKey(__FILE__);
$shm = new SharedData($key);
do {
$counter = $shm->get("counter") + 1;
} while (!$shm->set("counter", $counter, true));
$shm->destroy();
The `SharedMemory` class is a simple integer-indexed array
$key = new FileKey(__FILE__);
$shm = new SharedMemory($key);
$shm[0] = 42;
$shm->destroy();
## Communication ## Communication