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