Sync

目次

The SyncMutex class

はじめに

A cross-platform, native implementation of named and unnamed countable mutex objects.

A mutex is a mutual exclusion object that restricts access to a shared resource (e.g. a file) to a single instance. Countable mutexes acquire the mutex a single time and internally track the number of times the mutex is locked. The mutex is unlocked as soon as it goes out of scope or is unlocked the same number of times that it was locked.

クラス概要

SyncMutex
class SyncMutex {
/* メソッド */
public __construct(string $name = ?)
public bool lock(int $wait = -1)
public bool unlock(bool $all = false)
}

The SyncSemaphore class

はじめに

A cross-platform, native implementation of named and unnamed semaphore objects.

A semaphore restricts access to a limited resource to a limited number of instances. Semaphores differ from mutexes in that they can allow more than one instance to access a resource at one time while a mutex only allows one instance at a time.

クラス概要

SyncSemaphore
class SyncSemaphore {
/* メソッド */
public __construct(string $name = ?, int $initialval = 1, bool $autounlock = true)
public bool lock(int $wait = -1)
public bool unlock(int &$prevcount = ?)
}

The SyncEvent class

はじめに

A cross-platform, native implementation of named and unnamed event objects. Both automatic and manual event objects are supported.

An event object waits, without polling, for the object to be fired/set. One instance waits on the event object while another instance fires/sets the event. Event objects are useful wherever a long-running process would otherwise poll a resource (e.g. checking to see if uploaded data needs to be processed).

クラス概要

SyncEvent
class SyncEvent {
/* メソッド */
public __construct(string $name = ?, bool $manual = false, bool $prefire = false)
public bool fire()
public bool reset()
public bool wait(int $wait = -1)
}

The SyncReaderWriter class

はじめに

A cross-platform, native implementation of named and unnamed reader-writer objects.

A reader-writer object allows many readers or one writer to access a resource. This is an efficient solution for managing resources where access will primarily be read-only but exclusive write access is occasionally necessary.

クラス概要

SyncReaderWriter
class SyncReaderWriter {
/* メソッド */
public __construct(string $name = ?, int $autounlock = 1)
public bool readlock(int $wait = -1)
public bool readunlock()
public bool writelock(int $wait = -1)
public bool writeunlock()
}

The SyncSharedMemory class

はじめに

A cross-platform, native, consistent implementation of named shared memory objects.

Shared memory lets two separate processes communicate without the need for complex pipes or sockets. There are several integer-based shared memory implementations for PHP. Named shared memory is an alternative.

Synchronization objects (e.g. SyncMutex) are still required to protect most uses of shared memory.

クラス概要

SyncSharedMemory
class SyncSharedMemory {
/* メソッド */
public __construct(string $name, int $size)
public bool first()
public read(int $start = 0, int $length = ?)
public int size()
public write(string $string = ?, int $start = 0)
}