pthreads Threaded::wait
(PECL pthreads >= 2.0.0)
Threaded::wait — Synchronization
설명
public Threaded::wait(int $timeout
= ?): bool
호출 컨텍스트가 참조된 개체의 알림을 기다리도록 합니다.
매개변수
timeout
- 마이크로초 단위의 선택적 제한 시간
반환 값
성공하면 true
를, 실패하면 false
를 반환합니다.
Examples
예제 #1 알림 및 대기
<?php
class My extends Thread {
public function run() {
/** cause this thread to wait **/
$this->synchronized(function($thread){
if (!$thread->done)
$thread->wait();
}, $this);
}
}
$my = new My();
$my->start();
/** send notification to the waiting thread **/
$my->synchronized(function($thread){
$thread->done = true;
$thread->notify();
}, $my);
var_dump($my->join());
?>
위의 예는 다음을 출력합니다.
bool(true)