mirror of
https://github.com/danog/parallel.git
synced 2024-11-30 04:39:01 +01:00
Documentation & unused argument fixes
This commit is contained in:
parent
6febc476b8
commit
25fbe7a9a8
@ -61,7 +61,9 @@ class FileMutex implements MutexInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* Releases the lock on the mutex.
|
||||
*
|
||||
* @throws MutexException If the unlock operation failed.
|
||||
*/
|
||||
protected function release()
|
||||
{
|
||||
@ -78,6 +80,8 @@ class FileMutex implements MutexInterface
|
||||
* Opens the mutex file and returns a file resource.
|
||||
*
|
||||
* @return resource
|
||||
*
|
||||
* @throws MutexException If the mutex file could not be opened.
|
||||
*/
|
||||
private function getFileHandle()
|
||||
{
|
||||
|
@ -45,7 +45,7 @@ class Lock
|
||||
/**
|
||||
* Releases the lock.
|
||||
*
|
||||
* @throws LockAlreadyReleasedError Thrown if the lock was already released.
|
||||
* @throws LockAlreadyReleasedError If the lock was already released.
|
||||
*/
|
||||
public function release()
|
||||
{
|
||||
|
@ -32,12 +32,12 @@ class PosixSemaphore implements SemaphoreInterface, \Serializable
|
||||
private $data;
|
||||
|
||||
/**
|
||||
* Creates a new semaphore.
|
||||
* Creates a new semaphore with a given number of locks.
|
||||
*
|
||||
* @param int $maxLocks The maximum number of processes that can lock the
|
||||
* semaphore.
|
||||
* @param int $maxLocks The maximum number of locks that can be acquired from the semaphore.
|
||||
* @param int $permissions Permissions to access the semaphore.
|
||||
*/
|
||||
public function __construct($maxLocks)
|
||||
public function __construct($maxLocks, $permissions = 0600)
|
||||
{
|
||||
$this->key = abs(crc32(spl_object_hash($this)));
|
||||
|
||||
|
@ -24,12 +24,12 @@ class Semaphore implements SemaphoreInterface, \Serializable
|
||||
private $handle;
|
||||
|
||||
/**
|
||||
* Creates a new semaphore.
|
||||
* Creates a new semaphore with a given number of locks.
|
||||
*
|
||||
* @param int $maxLocks The maximum number of processes that can lock the semaphore.
|
||||
* @param int $maxLocks The maximum number of locks that can be acquired from the semaphore.
|
||||
* @param int $permissions Permissions to access the semaphore.
|
||||
*/
|
||||
public function __construct($maxLocks = 1, $permissions = 0666)
|
||||
public function __construct($maxLocks = 1, $permissions = 0600)
|
||||
{
|
||||
$this->key = abs(crc32(spl_object_hash($this)));
|
||||
$this->maxLocks = $maxLocks;
|
||||
@ -106,6 +106,6 @@ class Semaphore implements SemaphoreInterface, \Serializable
|
||||
// Get the semaphore key and attempt to re-connect to the semaphore in
|
||||
// memory.
|
||||
list($this->key, $this->maxLocks) = unserialize($serialized);
|
||||
$this->handle = sem_get($this->key, $maxLocks, 0666, 1);
|
||||
$this->handle = sem_get($this->key, $maxLocks, 0600, 1);
|
||||
}
|
||||
}
|
||||
|
@ -29,9 +29,9 @@ class Semaphore extends \Threaded
|
||||
private $waitQueue = [];
|
||||
|
||||
/**
|
||||
* Creates a new semaphore.
|
||||
* Creates a new semaphore with a given number of locks.
|
||||
*
|
||||
* @param int $maxLocks The maximum number of processes that can lock the semaphore.
|
||||
* @param int $maxLocks The maximum number of locks that can be acquired from the semaphore.
|
||||
*/
|
||||
public function __construct($maxLocks)
|
||||
{
|
||||
|
@ -17,10 +17,8 @@ class Mutex implements MutexInterface
|
||||
|
||||
/**
|
||||
* Creates a new threaded mutex.
|
||||
*
|
||||
* @param bool $locked Whether the mutex should start out locked.
|
||||
*/
|
||||
public function __construct($locked = false)
|
||||
public function __construct()
|
||||
{
|
||||
$this->mutex = new Internal\Mutex();
|
||||
}
|
||||
|
@ -14,16 +14,18 @@ use Icicle\Concurrent\Sync\SemaphoreInterface;
|
||||
class Semaphore implements SemaphoreInterface
|
||||
{
|
||||
/**
|
||||
* @var \Icicle\Concurrent\Threading\Internal\Semaphore
|
||||
* @var Internal\Semaphore
|
||||
*/
|
||||
private $semaphore;
|
||||
|
||||
/**
|
||||
* @param int $maxLocks
|
||||
* Creates a new semaphore with a given number of locks.
|
||||
*
|
||||
* @param int $maxLocks The maximum number of locks that can be acquired from the semaphore.
|
||||
*/
|
||||
public function __construct($maxLocks)
|
||||
{
|
||||
$this->semaphore = new Internal\Semaphore($maxLocks);
|
||||
$this->semaphore = new Internal\Semaphore($locks);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -24,12 +24,12 @@ class Thread implements ContextInterface, SynchronizableInterface
|
||||
const LATENCY_TIMEOUT = 0.01; // 10 ms
|
||||
|
||||
/**
|
||||
* @var \Icicle\Concurrent\Threading\Internal\Thread An internal thread instance.
|
||||
* @var Internal\Thread An internal thread instance.
|
||||
*/
|
||||
private $thread;
|
||||
|
||||
/**
|
||||
* @var \Icicle\Concurrent\Sync\Channel A channel for communicating with the thread.
|
||||
* @var Channel A channel for communicating with the thread.
|
||||
*/
|
||||
private $channel;
|
||||
|
||||
@ -46,9 +46,9 @@ class Thread implements ContextInterface, SynchronizableInterface
|
||||
/**
|
||||
* Spawns a new thread and runs it.
|
||||
*
|
||||
* @param callable $function A callable to invoke in the thread.
|
||||
* @param callable $function The callable to invoke in the thread.
|
||||
*
|
||||
* @return \Icicle\Concurrent\Threading\Thread The thread object that was spawned.
|
||||
* @return Thread The thread object that was spawned.
|
||||
*/
|
||||
public static function spawn(callable $function /* , ...$args */)
|
||||
{
|
||||
@ -59,9 +59,11 @@ class Thread implements ContextInterface, SynchronizableInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new thread context from a thread.
|
||||
* Creates a new thread.
|
||||
*
|
||||
* @param callable $function
|
||||
* @param callable $function The callable to invoke in the thread when run.
|
||||
*
|
||||
* @throws InvalidArgumentError If the given function cannot be safely invoked in a thread.
|
||||
*/
|
||||
public function __construct(callable $function /* , ...$args */)
|
||||
{
|
||||
@ -92,7 +94,9 @@ class Thread implements ContextInterface, SynchronizableInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the context execution.
|
||||
* Spawns the thread and begins the thread's execution.
|
||||
*
|
||||
* @throws StatusError If the thread has already been started.
|
||||
*/
|
||||
public function start()
|
||||
{
|
||||
@ -107,6 +111,8 @@ class Thread implements ContextInterface, SynchronizableInterface
|
||||
|
||||
/**
|
||||
* Immediately kills the context.
|
||||
*
|
||||
* @throws ThreadException If killing the thread was unsuccessful.
|
||||
*/
|
||||
public function kill()
|
||||
{
|
||||
@ -128,8 +134,8 @@ class Thread implements ContextInterface, SynchronizableInterface
|
||||
*
|
||||
* @resolve mixed Resolved with the return or resolution value of the context once it has completed execution.
|
||||
*
|
||||
* @throws \Icicle\Concurrent\Exception\StatusError Thrown if the context has not been started.
|
||||
* @throws \Icicle\Concurrent\Exception\SynchronizationError Thrown if an exit status object is not received.
|
||||
* @throws StatusError Thrown if the context has not been started.
|
||||
* @throws SynchronizationError Thrown if an exit status object is not received.
|
||||
*/
|
||||
public function join()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user