本文整理汇总了TypeScript中@jonggrang/avar.putAVar函数的典型用法代码示例。如果您正苦于以下问题:TypeScript putAVar函数的具体用法?TypeScript putAVar怎么用?TypeScript putAVar使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了putAVar函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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:
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));
});
示例3: 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));
});
示例4:
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>])
)
示例5: pure
return pure(readRef(currRef).chain(mv => {
return isLeft(mv) ? putAVar(needsRunning, null).chain(() => readAVar(mv.value))
/* otherwise */ : pure(mv.value);
}));
示例6:
AV.tryTakeAVar(msem.headWait).chain(extraFlags =>
P.isNothing(extraFlags) ? T.pure(quantity)
: /* otherwise */ AV.putAVar(msem.headWait, void 0).map(() => quantity + 1)
示例7: ChannelItem
.chain(oldHole =>
T.apSecond(
AV.putAVar(oldHole, new ChannelItem(val, newHole)),
AV.putAVar(chan.write, newHole)
)