Skip to content

Commit

Permalink
documentation updates for Swoole v6 (#41)
Browse files Browse the repository at this point in the history
* update updates since v6.0.0

Signed-off-by: Demin Yin <[email protected]>

* use constants as should

Signed-off-by: Demin Yin <[email protected]>

* documentation updates

Signed-off-by: Demin Yin <[email protected]>

* documentation updates

Signed-off-by: Demin Yin <[email protected]>

* document class \Swoole\Thread\Barrier

Signed-off-by: Demin Yin <[email protected]>

---------

Signed-off-by: Demin Yin <[email protected]>
  • Loading branch information
deminy authored Jan 5, 2025
1 parent 2087b68 commit c4be637
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/swoole/Swoole/Async/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Swoole\Async;

/**
* @since 6.0.0-rc1
* @since 6.0.0
*/
class Client extends \Swoole\Client
{
Expand Down
3 changes: 1 addition & 2 deletions src/swoole/Swoole/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ public function shutdown(int $how): bool
* option "--enable-openssl" included).
*
* @param callable|null $onSslReady Callback function to be executed when SSL handshake is successful.
* Added in v6.0.0-rc1 for child class Swoole\Async\Client only. It has no effect
* on this class.
* Added in v6.0.0 for child class Swoole\Async\Client only. It has no effect on this class.
* @return bool TRUE if SSL handshake is successful; otherwise FALSE.
*/
public function enableSSL(?callable $onSslReady = null): bool
Expand Down
2 changes: 1 addition & 1 deletion src/swoole/Swoole/Coroutine.php
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ public static function waitPid(int $pid, float $timeout = -1): array|false
* Wait for given signal(s) with a timeout.
*
* @param int|array<int> $signals An integer or an array of integers representing the signal number(s).
* Before Swoole v6.0.0-rc1, only integer is supported.
* Before Swoole v6.0.0, only integer is supported.
* @param float $timeout The timeout value in seconds. Minimum value is 0.001. -1 means no timeout.
* @return int|false Returns the signal number received on success, or false on failure.
* @alias Alias of method \Swoole\Coroutine\System::waitSignal().
Expand Down
2 changes: 1 addition & 1 deletion src/swoole/Swoole/Coroutine/Http/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function set(array $settings): bool
* @param string $pattern The URL pattern to match, e.g., "/index".
* @param callable $callback The callback function to handle the HTTP request.
* @return bool Return true on success. Return false on failure.
* Before Swoole v6.0.0-rc1, it returns void.
* Before Swoole v6.0.0, it returns void.
*/
public function handle(string $pattern, callable $callback): bool
{
Expand Down
2 changes: 1 addition & 1 deletion src/swoole/Swoole/Coroutine/System.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public static function waitPid(int $pid, float $timeout = -1): array|false
* Wait for given signal(s) with a timeout.
*
* @param int|array<int> $signals An integer or an array of integers representing the signal number(s).
* Before Swoole v6.0.0-rc1, only integer is supported.
* Before Swoole v6.0.0, only integer is supported.
* @param float $timeout The timeout value in seconds. Minimum value is 0.001. -1 means no timeout.
* @return int|false Returns the signal number received on success, or false on failure.
* @alias This method has an alias of \Swoole\Coroutine::waitSignal().
Expand Down
2 changes: 1 addition & 1 deletion src/swoole/Swoole/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Process
*
* @param callable $callback The callback function of the process.
*/
public function __construct(callable $callback, bool $redirect_stdin_and_stdout = false, int $pipe_type = 2, bool $enable_coroutine = false)
public function __construct(callable $callback, bool $redirect_stdin_and_stdout = false, int $pipe_type = SOCK_DGRAM, bool $enable_coroutine = false)
{
}

Expand Down
25 changes: 25 additions & 0 deletions src/swoole/Swoole/Thread/ArrayList.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,38 @@ public function __construct(?array $array = null)
{
}

/**
* @see \ArrayAccess::offsetGet()
* @see https://www.php.net/manual/en/arrayaccess.offsetget.php
* {@inheritDoc}
*/
public function offsetGet(mixed $key): mixed
{
}

/**
* @see \ArrayAccess::offsetExists()
* @see https://www.php.net/manual/en/arrayaccess.offsetexists.php
* {@inheritDoc}
*/
public function offsetExists(mixed $key): bool
{
}

/**
* @see \ArrayAccess::offsetSet()
* @see https://www.php.net/manual/en/arrayaccess.offsetset.php
* {@inheritDoc}
*/
public function offsetSet(mixed $key, mixed $value): void
{
}

/**
* @see \ArrayAccess::offsetUnset()
* @see https://www.php.net/manual/en/arrayaccess.offsetunset.php
* {@inheritDoc}
*/
public function offsetUnset(mixed $key): void
{
}
Expand All @@ -52,6 +72,11 @@ public function clean(): void
{
}

/**
* @see \Countable::count()
* @see https://www.php.net/manual/en/countable.count.php
* {@inheritDoc}
*/
public function count(): int
{
}
Expand Down
17 changes: 16 additions & 1 deletion src/swoole/Swoole/Thread/Barrier.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
namespace Swoole\Thread;

/**
* Class \Swoole\Thread\Barrier.
* A synchronization mechanism that allows multiple threads to wait at a barrier point until the specified number of
* threads has reached the barrier.
*
* Once the required number of threads has arrived, all threads are released simultaneously.
*
* This class is available only when PHP is compiled with Zend Thread Safety (ZTS) enabled and Swoole is installed with
* the "--enable-swoole-thread" configuration option.
Expand All @@ -14,10 +17,22 @@
*/
final class Barrier
{
/**
* Initializes a new barrier with a specified thread count.
*
* @param int $count The number of threads required to meet at the barrier before they can proceed.
* This value must be greater than 0.
*/
public function __construct(int $count)
{
}

/**
* Blocks the current thread until the specified number of threads (provided in the constructor)
* have invoked this method.
*
* Once all threads have called this method, the barrier is lifted, and all waiting threads proceed.
*/
public function wait(): void
{
}
Expand Down
14 changes: 5 additions & 9 deletions src/swoole/Swoole/Thread/Lock.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,15 @@
*/
final class Lock
{
public const RWLOCK = 1;
public const RWLOCK = SWOOLE_RWLOCK;

public const MUTEX = 3;
public const MUTEX = SWOOLE_MUTEX;

public const SPINLOCK = 5;
public const SPINLOCK = SWOOLE_SPINLOCK;

public $errCode = 0;
public int $errCode = 0;

public function __construct(int $type = 3)
{
}

public function __destruct()
public function __construct(int $type = self::MUTEX)
{
}

Expand Down
25 changes: 25 additions & 0 deletions src/swoole/Swoole/Thread/Map.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,38 @@ public function __construct(?array $array = null)
{
}

/**
* @see \ArrayAccess::offsetGet()
* @see https://www.php.net/manual/en/arrayaccess.offsetget.php
* {@inheritDoc}
*/
public function offsetGet(mixed $key): mixed
{
}

/**
* @see \ArrayAccess::offsetExists()
* @see https://www.php.net/manual/en/arrayaccess.offsetexists.php
* {@inheritDoc}
*/
public function offsetExists(mixed $key): bool
{
}

/**
* @see \ArrayAccess::offsetSet()
* @see https://www.php.net/manual/en/arrayaccess.offsetset.php
* {@inheritDoc}
*/
public function offsetSet(mixed $key, mixed $value): void
{
}

/**
* @see \ArrayAccess::offsetUnset()
* @see https://www.php.net/manual/en/arrayaccess.offsetunset.php
* {@inheritDoc}
*/
public function offsetUnset(mixed $key): void
{
}
Expand All @@ -38,6 +58,11 @@ public function find(mixed $value): mixed
{
}

/**
* @see \Countable::count()
* @see https://www.php.net/manual/en/countable.count.php
* {@inheritDoc}
*/
public function count(): int
{
}
Expand Down
5 changes: 3 additions & 2 deletions src/swoole/Swoole/Thread/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class Queue implements \Countable
public const NOTIFY_ONE = 1;

/**
* Unblocks all threads currently waiting for this queue.
* Unblock all threads currently waiting for this queue.
*
* This constant is used by method Queue::push() only.
*/
Expand All @@ -32,7 +32,8 @@ final class Queue implements \Countable
* Push a value into the queue.
*
* @param mixed $value The value to push into the queue.
* @param int $notify_which How to unblock threads that are waiting on the queue. Either NOTIFY_ONE, NOTIFY_ALL, or 0 (not to notify anyone).
* @param int $notify_which How to unblock threads that are waiting on the queue. Either Queue::NOTIFY_ONE,
* Queue::NOTIFY_ALL, or 0 (not to notify anyone).
*/
public function push(mixed $value, int $notify_which = 0): void
{
Expand Down
4 changes: 2 additions & 2 deletions src/swoole/constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@
#ifdef HAVE_SPINLOCK
define('SWOOLE_SPINLOCK', 5); # Supported only if the Spin Locks option is provided in the POSIX thread (pthread) libraries.
#endif
define('SWOOLE_COROLOCK', 6); # @since v6.0.0-rc1
define('SWOOLE_COROLOCK', 6); # @since v6.0.0

/*
* Following SIG_* and PRIO_* constants are set only when PHP extension pcntl (to support Process Control) is not
Expand Down Expand Up @@ -592,7 +592,7 @@
*/
define('SOCKET_ECANCELED', 125);

define('TCP_INFO', 11); // @since v6.0.0-rc1
define('TCP_INFO', 11); // @since v6.0.0

/*
* Constants in this section are used in Swoole servers.
Expand Down

0 comments on commit c4be637

Please sign in to comment.