mirror of
https://github.com/janet-lang/janet
synced 2024-09-29 23:40:40 +00:00
Merge branch 'master' into localbindings
This commit is contained in:
commit
c7fb7b4451
@ -3590,13 +3590,18 @@
|
|||||||
(,ev/deadline ,deadline nil ,f)
|
(,ev/deadline ,deadline nil ,f)
|
||||||
(,resume ,f))))
|
(,resume ,f))))
|
||||||
|
|
||||||
|
(defn- cancel-all [fibers reason] (each f fibers (ev/cancel f reason) (put fibers f nil)))
|
||||||
|
|
||||||
(defn- wait-for-fibers
|
(defn- wait-for-fibers
|
||||||
[chan fibers]
|
[chan fibers]
|
||||||
|
(defer (cancel-all fibers "parent canceled")
|
||||||
(repeat (length fibers)
|
(repeat (length fibers)
|
||||||
(def [sig fiber] (ev/take chan))
|
(def [sig fiber] (ev/take chan))
|
||||||
(unless (= sig :ok)
|
(if (= sig :ok)
|
||||||
(each f fibers (ev/cancel f "sibling canceled"))
|
(put fibers fiber nil)
|
||||||
(propagate (fiber/last-value fiber) fiber))))
|
(do
|
||||||
|
(cancel-all fibers "sibling canceled")
|
||||||
|
(propagate (fiber/last-value fiber) fiber))))))
|
||||||
|
|
||||||
(defmacro ev/gather
|
(defmacro ev/gather
|
||||||
``
|
``
|
||||||
@ -3604,13 +3609,16 @@
|
|||||||
Returns the gathered results in an array.
|
Returns the gathered results in an array.
|
||||||
``
|
``
|
||||||
[& bodies]
|
[& bodies]
|
||||||
(with-syms [chan res]
|
(with-syms [chan res fset ftemp]
|
||||||
~(do
|
~(do
|
||||||
|
(def ,fset @{})
|
||||||
(def ,chan (,ev/chan))
|
(def ,chan (,ev/chan))
|
||||||
(def ,res @[])
|
(def ,res @[])
|
||||||
(,wait-for-fibers ,chan
|
,;(seq [[i body] :pairs bodies]
|
||||||
,(seq [[i body] :pairs bodies]
|
~(do
|
||||||
~(,ev/go (fn [] (put ,res ,i ,body)) nil ,chan)))
|
(def ,ftemp (,ev/go (fn [] (put ,res ,i ,body)) nil ,chan))
|
||||||
|
(,put ,fset ,ftemp ,ftemp)))
|
||||||
|
(,wait-for-fibers ,chan ,fset)
|
||||||
,res))))
|
,res))))
|
||||||
|
|
||||||
(compwhen (dyn 'net/listen)
|
(compwhen (dyn 'net/listen)
|
||||||
|
@ -172,6 +172,9 @@ static JanetTimestamp ts_now(void);
|
|||||||
|
|
||||||
/* Get current timestamp + an interval (millisecond precision) */
|
/* Get current timestamp + an interval (millisecond precision) */
|
||||||
static JanetTimestamp ts_delta(JanetTimestamp ts, double delta) {
|
static JanetTimestamp ts_delta(JanetTimestamp ts, double delta) {
|
||||||
|
if (isinf(delta)) {
|
||||||
|
return delta < 0 ? ts : INT64_MAX;
|
||||||
|
}
|
||||||
ts += (int64_t)round(delta * 1000);
|
ts += (int64_t)round(delta * 1000);
|
||||||
return ts;
|
return ts;
|
||||||
}
|
}
|
||||||
|
@ -955,6 +955,7 @@ static int line() {
|
|||||||
break;
|
break;
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
case 26: /* ctrl-z */
|
case 26: /* ctrl-z */
|
||||||
|
clearlines();
|
||||||
norawmode();
|
norawmode();
|
||||||
kill(getpid(), SIGSTOP);
|
kill(getpid(), SIGSTOP);
|
||||||
rawmode();
|
rawmode();
|
||||||
|
Loading…
Reference in New Issue
Block a user