首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

Worker (class)

Introduction

(PECL pthreads >= 2.0.0)

Worker Threads have a persistent context, as such should be used over Threads in most cases.

When a Worker is started, the run method will be executed, but the Thread will not leave until one of the following conditions are met:

  • the Worker goes out of scope (no more references remain)
  • the programmer calls shutdown
  • the script dies This means the programmer can reuse the context throughout execution; placing objects on the stack of the Worker will cause the Worker to execute the stacked objects run method. Class synopsis Worker extends Thread implements Traversable , Countable , ArrayAccess {/* Methods */public int collect ([ Callable $collector ] )public int getStacked ( void )public bool isShutdown ( void )public boolean isWorking ( void )public bool shutdown ( void )public int stack ( Threaded &$work )public int unstack ( void )/* Inherited methods */public void Thread::detach ( void )public integer Thread::getCreatorId ( void )public static Thread Thread::getCurrentThread ( void )public static integer Thread::getCurrentThreadId ( void )public integer Thread::getThreadId ( void )public static mixed Thread::globally ( void )public boolean Thread::isJoined ( void )public boolean Thread::isStarted ( void )public boolean Thread::join ( void )public void Thread::kill ( void )public boolean Thread::start ([ integer $options ] ) }Table of Contents
  • Worker::collect — Collect references to completed tasks
  • Worker::getStacked — Gets the remaining stack size
  • Worker::isShutdown — State Detection
  • Worker::isWorking — State Detection
  • Worker::shutdown — Shutdown the worker
  • Worker::stack — Stacking work
  • Worker::unstack — Unstacking work

← Thread::start

Worker::collect →

代码语言:txt
复制
 ? 1997–2017 The PHP Documentation Group

Licensed under the Creative Commons Attribution License v3.0 or later.

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com