pthreads Threaded::notifyOne
(PECL pthreads >= 3.0.0)
Threaded::notifyOne — Synchronization
설명
public Threaded::notifyOne(): bool
참조된 개체에 알림을 보냅니다. 이것은 차단된 스레드 중 하나 이상을 차단 해제합니다(Threaded::notify()에서 볼 수 있는 모든 차단 해제와 반대).
매개변수
이 함수에는 매개변수가 없습니다.
반환 값
성공하면 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->notifyOne();
}, $my);
var_dump($my->join());
?>
위의 예는 다음을 출력합니다.
bool(true)