PHP 8.4.2 Released!

A classe Threaded

(PECL pthreads >= 2.0.0)

Introdução

Objetos threaded formam a base da capacidade do pthreads de executar código do usuário em paralelo; eles expõem métodos de sincronização e várias interfaces úteis.

Objetos threaded, mais importante ainda, fornecem segurança implícita para o programador; todas as operações no escopo do objeto são seguras.

Resumo da classe

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

Índice

adicione uma nota

Notas Enviadas por Usuários (em inglês) 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