# \PG\MSF\TasksTask

Class Task

## Summary

Methods
Properties
Constants
__construct()
__call()
setTimeout()
getTimeout()
startTask()
destroy()
__sleep()
__unsleep()
getServerInstance()
getConfig()
getPack()
getRedisPool()
getMysqlPool()
getRedisProxy()
setRedisPools()
setRedisProxies()
isUse()
getIsDestroy()
setContext()
__initialization()
$taskName
$taskConstruct
$__useCount
$__genTime
$__isContruct
$stdClass
No constants found
No protected methods found
$timeout
$taskId
$__isDestroy
$redisPools
$mysqlPools
$redisProxies
$reflections
N/A
No private methods found
$taskProxyData
N/A

File
  Tasks/Task.php
Package
  MSF\Tasks
Class hierarchy
  \PG\MSF\Base\Child
  \PG\MSF\Base\Core
  \PG\MSF\Tasks\TaskProxy
  \PG\MSF\Tasks\Task

## Tags

None found

## Properties

### $taskName

    $taskName : string

#### Type

string — 执行的Task Name

#

Inherited from
  \PG\MSF\Tasks\TaskProxy

## Tags

None found

### $taskConstruct

    $taskConstruct : array

#### Type

array — Task构造参数

#

Inherited from
  \PG\MSF\Tasks\TaskProxy

## Tags

None found

### $__useCount

    $__useCount : integer

#### Type

integer — 作用计数

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### $__genTime

    $__genTime : integer

#### Type

integer — 创建时间

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### $__isContruct

    $__isContruct : boolean

#### Type

boolean — 是否执行构造方法

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### $stdClass

    $stdClass : \stdClass|null

#### Type

\stdClass|null — 对象模板

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### $timeout

    $timeout : integer

#### Type

integer — 任务执行超时时间

#

Inherited from
  \PG\MSF\Tasks\TaskProxy

## Tags

None found

### $taskId

    $taskId : integer

#### Type

integer — 任务ID

#

Inherited from
  \PG\MSF\Tasks\TaskProxy

## Tags

None found

### $__isDestroy

    $__isDestroy : boolean

#### Type

boolean — 销毁标志

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### $redisPools

    $redisPools : array

#### Type

array — redis连接池

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### $mysqlPools

    $mysqlPools : array

#### Type

array — mysql连接池

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### $redisProxies

    $redisProxies : array

#### Type

array — redis代理池

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### $reflections

    $reflections : array

#### Type

array — 反射类属性的默认值

#

Inherited from
  \PG\MSF\Base\Child

## Tags

None found

### $taskProxyData

    $taskProxyData : mixed

#### Type

mixed — task执行数据

#

Inherited from
  \PG\MSF\Tasks\TaskProxy

## Tags

None found

## Methods

### __construct()

    __construct()

Task constructor.

#

## Tags

None found

### __call()

    __call(string  $name, array  $arguments) : \PG\MSF\Coroutine\CTask

__call魔术方法

#### Parameters

string | $name | 任务方法名
array | $arguments | 执行参数

#### Returns

\PG\MSF\Coroutine\CTask

#

Inherited from
  \PG\MSF\Tasks\TaskProxy

## Tags

None found

### setTimeout()

    setTimeout(integer  $timeout) : $this

设置任务执行超时时间

#### Parameters

integer | $timeout | 超时时间，单位毫秒

#### Returns

$this

#

Inherited from
  \PG\MSF\Tasks\TaskProxy

## Tags

None found

### getTimeout()

    getTimeout() : integer

获取任务执行超时时间

#### Returns

integer

#

Inherited from
  \PG\MSF\Tasks\TaskProxy

## Tags

None found

### startTask()

    startTask(callable|null  $callback = null)

异步任务

#### Parameters

callable|null | $callback | 任务执行完成的回调

#

Inherited from
  \PG\MSF\Tasks\TaskProxy

## Tags

None found

### destroy()

    destroy()

销毁

#

## Tags

None found

### __sleep()

    __sleep() : array

在序列化及dump对象时使用，代表哪些属于需要导出

#### Returns

array

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### __unsleep()

    __unsleep()

和__sleep作用相反

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### getServerInstance()

    getServerInstance() : \swoole_server

获取运行Server实例

#### Returns

\swoole_server

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### getConfig()

    getConfig() : \Noodlehaus\Config

获取运行server实例配置对象

#### Returns

\Noodlehaus\Config

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### getPack()

    getPack() : \PG\MSF\Pack\IPack

获取运行server实例打包对象

#### Returns

\PG\MSF\Pack\IPack

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### getRedisPool()

    getRedisPool(string  $poolName) : boolean|\PG\AOP\Wrapper|\PG\MSF\Pools\CoroutineRedisProxy|\Redis

获取Redis连接池

#### Parameters

string | $poolName | 配置的Redis连接池名称

#### Returns

boolean|\PG\AOP\Wrapper|\PG\MSF\Pools\CoroutineRedisProxy|\Redis

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### getMysqlPool()

    getMysqlPool(string  $poolName) : boolean|\PG\AOP\Wrapper

获取MySQL连接池

#### Parameters

string | $poolName | 配置的MySQL连接池名称

#### Returns

boolean|\PG\AOP\Wrapper

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### getRedisProxy()

    getRedisProxy(string  $proxyName) : boolean|\PG\AOP\Wrapper|\PG\MSF\Pools\CoroutineRedisProxy|\Redis

获取Redis代理

#### Parameters

string | $proxyName | 配置的Redis代理名称

#### Throws

\Exception

#### Returns

boolean|\PG\AOP\Wrapper|\PG\MSF\Pools\CoroutineRedisProxy|\Redis

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### setRedisPools()

    setRedisPools(array|null  $redisPools) : $this

设置RedisPools

#### Parameters

array|null | $redisPools | 多个Redis连接池实例，通常用于销毁Redis连接池，赋值为NULL

#### Returns

$this

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### setRedisProxies()

    setRedisProxies(array|null  $redisProxies) : $this

设置RedisPools

#### Parameters

array|null | $redisProxies | 多个Redis代理实例，通常用于销毁Redis代理，赋值为NULL

#### Returns

$this

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### isUse()

    isUse()

对象已使用标识

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### getIsDestroy()

    getIsDestroy() : boolean

是否已经执行destroy

#### Returns

boolean

#

Inherited from
  \PG\MSF\Base\Core

## Tags

None found

### setContext()

    setContext(\PG\MSF\Helpers\Context  $context) : $this

设置上下文

#### Parameters

\PG\MSF\Helpers\Context | $context | 请求上下文对象

#### Returns

$this

#

Inherited from
  \PG\MSF\Base\Child

## Tags

None found

### __initialization()

    __initialization(integer  $taskId, integer  $workerPid, string  $taskName, string  $methodName, \PG\MSF\Helpers\Context  $context, \PG\AOP\Wrapper|\PG\MSF\Base\Pool  $objectPool)

Tasker进程中初始化任务

#### Parameters

integer | $taskId | Task ID
integer | $workerPid | worker pid
string | $taskName | 任务类名
string | $methodName | 任务类方法
\PG\MSF\Helpers\Context | $context | 请求上下文对象
\PG\AOP\Wrapper|\PG\MSF\Base\Pool | $objectPool | 对象池对象

#

## Tags

None found

### Task.php