本文整理汇总了TypeScript中@jonggrang/task.forkTask函数的典型用法代码示例。如果您正苦于以下问题:TypeScript forkTask函数的具体用法?TypeScript forkTask怎么用?TypeScript forkTask使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了forkTask函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('writing unblocks reads', function* () {
const chan: Q.Chan<number> = yield Q.newChan;
yield T.forkTask(T.apSecond(T.delay(20), Q.writeChan(chan, 1)));
const r: P.Either<void, number> = yield compete(T.delay(50), Q.readChan(chan));
assert.ok(P.isRight(r));
return T.pure(void 0);
});
示例2:
function spawn<W, I>(
settings: ReaperSettings<W, I>,
stateRef: R.Ref<State<W>>,
tidRef: R.Ref<T.Fiber<void> | undefined>
): T.Task<void> {
return T.forkTask(reaper(settings, stateRef, tidRef))
.chain(fib => R.writeRef(tidRef, fib));
}
示例3:
return T.co(function* () {
const baton: AV.AVar<null> = yield AV.newEmptyAVar;
yield T.forkTask(T.forever(T.co(function* () {
yield AV.takeAVar(baton);
yield T.apathize(settings.action);
return T.delay(settings.frequency);
})));
return T.pure(AV.putAVar(baton, null));
});
示例4: co
return co(function* () {
let needsRunning: AVar<null> = yield newEmptyAVar;
let responseVar0: AVar<A> = yield newEmptyAVar;
let currRef: Ref<Either<AVar<A>, A>> = yield newRef(left(responseVar0));
function loop(responseVar: AVar<A>, ma: Maybe<A>): Task<void> {
return co(function* () {
yield takeAVar(needsRunning);
const a: A = yield maybe(set.task, identity, applyMaybe(modify, ma)) as Task<A>;
yield writeRef(currRef, right(a));
yield putAVar(responseVar, a);
yield delay(set.delay);
const responseVar_: AVar<A> = yield newEmptyAVar;
yield writeRef(currRef, left(responseVar_));
return loop(responseVar_, just(a));
});
}
yield forkTask(loop(responseVar0, nothing));
return pure(readRef(currRef).chain(mv => {
return isLeft(mv) ? putAVar(needsRunning, null).chain(() => readAVar(mv.value))
/* otherwise */ : pure(mv.value);
}));
});
示例5:
return AV.newEmptyAVar.chain(avar =>
T.forkTask(T.ensure(t, AV.putAVar(avar, void 0))).chain(fib =>
T.delay(10).map(() => [fib, avar] as [T.Fiber<A>, AV.AVar<void>])
)
示例6:
AV.newEmptyAVar.chain(avar =>
T.forkTask(T.delay(15).then(AV.putAVar(avar, 1)))
.then(AV.takeAVar(avar))
示例7: Error
.chain(av =>
T.forkTask(
AV.withAVar(av, () => T.delay(100)))
.chain(fib =>
T.killFiber(new Error('kill withAVar action'), fib))
.then(AV.takeAVar(av)))
示例8:
).chain(() =>
T.forkTask(T.node(null, path, permission, FS.chmod))