本文整理汇总了TypeScript中@jonggrang/avar.takeAVar函数的典型用法代码示例。如果您正苦于以下问题:TypeScript takeAVar函数的具体用法?TypeScript takeAVar怎么用?TypeScript takeAVar使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了takeAVar函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: test
test('FIFO semantics for the waiters', function* () {
const qsem: Q.QSem = yield Q.newQSem(0);
const [t1, m1]: Forked<void> = yield fork(Q.waitQSem(qsem));
yield stop(t1, m1);
yield Q.signalQSem(qsem);
yield T.delay(10);
const [t2, m2]: Forked<void> = yield fork(Q.waitQSem(qsem));
yield T.delay(10);
const result: AV.AVar<boolean> = yield AV.newEmptyAVar;
const [t3, m3]: Forked<void> = yield fork(
T.onException(
Q.waitQSem(qsem),
AV.putAVar(result, false)
).chain(() => AV.putAVar(result, true))
);
yield Q.signalQSem(qsem);
yield T.delay(10);
yield stop(t2, m2);
yield stop(t3, m3);
const r: boolean = yield AV.takeAVar(result);
assert.ok(r);
return T.pure(void 0);
});
示例2: waitSignal
]).chain(() => {
return T.race([
waitSignal('SIGINT'),
waitSignal('SIGTERM'),
settings.killToken == null ? T.never : takeAVar(settings.killToken)
]);
});
示例3: ChannelItem
.chain(newHole =>
AV.takeAVar(chan.write)
.chain(oldHole =>
T.apSecond(
AV.putAVar(oldHole, new ChannelItem(val, newHole)),
AV.putAVar(chan.write, newHole)
)
)
示例4: co
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));
});
示例5:
yield T.forkTask(T.forever(T.co(function* () {
yield AV.takeAVar(baton);
yield T.apathize(settings.action);
return T.delay(settings.frequency);
})));
示例6:
.chain(() => T.delay(10).chain(() => AV.takeAVar(av)));
示例7:
AV.tryTakeAVar(qsem.headWait).chain(mayGrab =>
P.isJust(mayGrab) ? T.pure([quantity, T.pure(void 0)] as [number, T.Task<void>])
: 0 < quantity ? T.pure([quantity - 1, T.pure(void 0)] as [number, T.Task<void>])
: /* otherwise */ T.pure([quantity, AV.takeAVar(qsem.headWait)] as [number, T.Task<void>])