# \PG\MSF\CoroutineTask

Class Task

## Summary

Methods
Properties
Constants
__construct()
resetRoutine()
getCallBack()
resetCallBack()
getController()
setException()
run()
handleTaskTimeout()
handleTaskException()
isFinished()
getRoutine()
destroy()
$destroy
No constants found
No protected methods found
$routine
$stack
$controller
$id
$exception
$callBack
N/A
No private methods found
No private properties found
N/A

File
  Coroutine/Task.php
Package
  MSF\Coroutine
Class hierarchy
  \PG\MSF\Coroutine\Task
Uses traits
  \PG\AOP\MI

## Tags

None found

## Properties

### $destroy

    $destroy : boolean

#### Type

boolean — 任务销毁标识

#

## Tags

None found

### $routine

    $routine : \Generator

#### Type

\Generator — 协程任务的迭代器

#

## Tags

None found

### $stack

    $stack : \SplStack

#### Type

\SplStack — 协程嵌套栈

#

## Tags

None found

### $controller

    $controller : \PG\MSF\Controllers\Controller

#### Type

\PG\MSF\Controllers\Controller — 请求的控制器

#

## Tags

None found

### $id

    $id : string

#### Type

string — 任务ID

#

## Tags

None found

### $exception

    $exception : \Throwable

#### Type

\Throwable — 迭代过程中的异常

#

## Tags

None found

### $callBack

    $callBack : callable|null

#### Type

callable|null — 迭代完成时执行回调函数

#

## Tags

None found

## Methods

### __construct()

    __construct(\Generator  $routine, \PG\MSF\Helpers\Context  $context, \PG\MSF\Controllers\Controller  $controller,   $callBack = null)

初始化方法

#### Parameters

\Generator | $routine | 待调度的迭代器实例
\PG\MSF\Helpers\Context | $context | 请求的上下文对象
\PG\MSF\Controllers\Controller | $controller | 当前请求控制器名称
| $callBack | callable|null 迭代器执行完成后回调函数

#

## Tags

None found

### resetRoutine()

    resetRoutine(\Generator  $routine = null) : $this

重置迭代器

#### Parameters

\Generator | $routine | 迭代器实例

#### Returns

$this

#

## Tags

None found

### getCallBack()

    getCallBack() : mixed

获取callback

#### Returns

mixed

#

## Tags

None found

### resetCallBack()

    resetCallBack(callable|null  $callBack = null) : $this

重置callback

#### Parameters

callable|null | $callBack | 迭代器执行完成后回调函数

#### Returns

$this

#

## Tags

None found

### getController()

    getController() : \PG\MSF\Controllers\Controller

获取controller

#### Returns

\PG\MSF\Controllers\Controller

#

## Tags

None found

### setException()

    setException(\Throwable  $exception)

设置调度时产生的异常

#### Parameters

\Throwable | $exception | 异常实例

#

## Tags

None found

### run()

    run()

请求的协程调度

#

## Tags

None found

### handleTaskTimeout()

    handleTaskTimeout(\Throwable  $e, mixed  $value) : \Throwable

处理协程任务的超时

#### Parameters

\Throwable | $e | 异常实例
mixed | $value | 当前迭代的值

#### Returns

\Throwable

#

## Tags

None found

### handleTaskException()

    handleTaskException(\Throwable  $e, mixed  $value) : boolean|\Exception|\Throwable

处理协程任务的异常

#### Parameters

\Throwable | $e | 异常实例
mixed | $value | 当前迭代的值

#### Returns

boolean|\Exception|\Throwable

#

## Tags

None found

### isFinished()

    isFinished() : boolean

[isFinished 判断该task是否完成]

#### Returns

boolean —

[description]

#

## Tags

None found

### getRoutine()

    getRoutine() : \Generator

获取协程任务当前正在运行的迭代器

#### Returns

\Generator

#

## Tags

None found

### destroy()

    destroy()

销毁

#

## Tags

None found

### Task.php