Threaded 类

(PECL pthreads >= 2.0.0)

简介

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

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

类摘要

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

目录

添加备注

用户贡献的备注 2 notes

up
6
derkontrollfreak+php at gmail dot com
9 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
5 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