Threaded 类

(PECL pthreads >= 2.0.0)

简介

Threaded 对象提供支持 pthreads 操作的基本功能,包括同步方法以及其他对程序员很有帮助的接口。

重要的是,Threaded 提供了隐式的线程安全机制,这个对象中的所有操作都是线程安全的。

类摘要

class Threaded implements Collectable, Traversable, Countable, ArrayAccess {
/* 方法 */
public function chunk(int $size, bool $preserve): array
public function count(): int
public function extend(string $class): bool
public function isRunning(): bool
public function isTerminated(): bool
publicfunction merge(mixed $from, bool $overwrite = ?): bool
public function notify(): bool
public function notifyOne(): bool
public function pop(): bool
public function run(): void
public function shift(): boolean
public function synchronized(Closure $block, mixed ...$args): mixed
public function wait(int $timeout = ?): bool
}

目录

添加备注

用户贡献的备注 2 notes

up
6
derkontrollfreak+php at gmail dot com
10 years ago
> Threaded objects, most importantly, provide implicit safety for the programmer; all operations on the object scope are safe.

However, this comes with a trade-off: Operations on the instance scope are slower than on plain PHP objects.

Static properties are not affected as they are thread-local.
up
2
jtbibliomania at gmail dot com
6 years ago
It's worth mentioning here that, since v2.0.0, 'Stackable' class was an alias for 'Threaded' class but has been removed since.
To Top