并发控制模块
引用方法:var coroutine = require(‘coroutine’);
| Type | Method and Description |
|---|---|
| void | public static static LockLockLock锁对象,参见 Lock |
| void | public static static SemaphoreSemaphoreSemaphore信号量对象,参见 Semaphore |
| void | public static static ConditionConditionCondition条件变量对象,参见 Condition |
| void | public static static EventEventEvent事件对象,参见 Event |
| void | public static static BlockQueueBlockQueueBlockQueue阻塞队列对象,参见 BlockQueue |
| void | public static static WorkerWorkerWorker独立线程工作对象,参见 Worker |
| readonly Array | public static readonly Array fibersfibersfibers返回当前正在运行的全部 fiber 数组 |
| Integer | public static Integer spareFibersspareFibersspareFibers查询和设置空闲 Fiber 数量,服务器抖动较大时可适度增加空闲 Fiber 数量。缺省为 256 |
| readonly Integer | public static readonly Integer vmidvmidvmid查询当前 vm 编号 |
| Integer | public static Integer loglevelloglevelloglevel修改和查询本 vm 的输出级别,用以过滤输出信息,缺省为 console.NOTSET,全部输出 |
| Type | Method and Description |
|---|---|
| Fiber | start(Function func,...)启动一个纤程并返回纤程对象 |
| Array | parallel(Array funcs,Integer fibers)并行执行一组函数,并等待返回 |
| Array | parallel(Array datas,Function func,Integer fibers)并行执行一个函数处理一组数据,并等待返回 |
| Array | parallel(Function func,Integer num,Integer fibers)并行执行一个函数多次,并等待返回 |
| Array | parallel(...)并行执行一组函数,并等待返回 |
| Fiber | current()返回当前纤程 |
| void | sleep(Integer ms)暂停当前纤程指定的时间 |
public static static LockLockLock锁对象,参见 Lock
public static static SemaphoreSemaphoreSemaphore信号量对象,参见 Semaphore
public static static ConditionConditionCondition条件变量对象,参见 Condition
public static static EventEventEvent事件对象,参见 Event
public static static BlockQueueBlockQueueBlockQueue阻塞队列对象,参见 BlockQueue
public static static WorkerWorkerWorker独立线程工作对象,参见 Worker
public static readonly Array fibersfibersfibers返回当前正在运行的全部 fiber 数组
public static Integer spareFibersspareFibersspareFibers查询和设置空闲 Fiber 数量,服务器抖动较大时可适度增加空闲 Fiber 数量。缺省为 256
public static readonly Integer vmidvmidvmid查询当前 vm 编号
public static Integer loglevelloglevelloglevel修改和查询本 vm 的输出级别,用以过滤输出信息,缺省为 console.NOTSET,全部输出
start(Function func,...)启动一个纤程并返回纤程对象
func 制定纤程执行的函数
... 可变参数序列,此序列会在纤程内传递给函数
返回纤程对象
parallel(Array funcs,Integer fibers)并行执行一组函数,并等待返回
funcs 并行执行的函数数组
fibers 限制并发 fiber 数量,缺省为 -1,启用与 funcs 数量相同 fiber
返回函数执行结果的数组
parallel(Array datas,Function func,Integer fibers)并行执行一个函数处理一组数据,并等待返回
datas 并行执行的数据数组
func 并行执行的函数
fibers 限制并发 fiber 数量,缺省为 -1,启用与 datas 数量相同 fiber
返回函数执行结果的数组
parallel(Function func,Integer num,Integer fibers)并行执行一个函数多次,并等待返回
func 并行执行的函数数
num 重复任务数量
fibers 限制并发 fiber 数量,缺省为 -1,启用与 funcs 数量相同 fiber
返回函数执行结果的数组
parallel(...)并行执行一组函数,并等待返回
... 一组并行执行的函数返回函数执行结果的数组
current()返回当前纤程
当前纤程对象
sleep(Integer ms)暂停当前纤程指定的时间
ms 指定要暂停的时间,以毫秒为单位,缺省为 0,即有空闲立即回恢复运行