本文整理匯總了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))