Merge branch 'master' of factorcode.org:/git/factor
commit
896949fbb8
|
@ -1,5 +1,6 @@
|
||||||
USING: alarms alarms.private kernel calendar sequences
|
USING: alarms alarms.private kernel calendar sequences
|
||||||
tools.test threads concurrency.count-downs ;
|
tools.test threads concurrency.count-downs concurrency.promises
|
||||||
|
fry tools.time math ;
|
||||||
IN: alarms.tests
|
IN: alarms.tests
|
||||||
|
|
||||||
[ ] [
|
[ ] [
|
||||||
|
@ -14,3 +15,17 @@ IN: alarms.tests
|
||||||
self [ resume ] curry instant later drop
|
self [ resume ] curry instant later drop
|
||||||
"test" suspend drop
|
"test" suspend drop
|
||||||
] unit-test
|
] unit-test
|
||||||
|
|
||||||
|
[ t ] [
|
||||||
|
[
|
||||||
|
<promise>
|
||||||
|
'[ t _ fulfill ] 5 seconds later drop
|
||||||
|
] benchmark 4,000,000,000 >
|
||||||
|
] unit-test
|
||||||
|
|
||||||
|
[ { 3 } ] [
|
||||||
|
{ 3 } dup
|
||||||
|
'[ 4 _ set-first ] 2 seconds later
|
||||||
|
1/2 seconds sleep
|
||||||
|
cancel-alarm
|
||||||
|
] unit-test
|
||||||
|
|
|
@ -144,7 +144,7 @@ M: stdin dispose*
|
||||||
tri
|
tri
|
||||||
] with-destructors ;
|
] with-destructors ;
|
||||||
|
|
||||||
: wait-for-stdin ( stdin -- n )
|
: wait-for-stdin ( stdin -- size )
|
||||||
[ control>> CHAR: X over io:stream-write1 io:stream-flush ]
|
[ control>> CHAR: X over io:stream-write1 io:stream-flush ]
|
||||||
[ size>> ssize_t heap-size swap io:stream-read *int ]
|
[ size>> ssize_t heap-size swap io:stream-read *int ]
|
||||||
bi ;
|
bi ;
|
||||||
|
@ -160,7 +160,12 @@ M: stdin dispose*
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
M: stdin refill
|
M: stdin refill
|
||||||
[ buffer>> ] [ dup wait-for-stdin ] bi* refill-stdin f ;
|
'[
|
||||||
|
buffer>> _ dup wait-for-stdin refill-stdin f
|
||||||
|
] with-timeout ;
|
||||||
|
|
||||||
|
M: stdin cancel-operation
|
||||||
|
[ size>> ] [ control>> ] bi [ cancel-operation ] bi@ ;
|
||||||
|
|
||||||
: control-write-fd ( -- fd ) &: control_write *uint ;
|
: control-write-fd ( -- fd ) &: control_write *uint ;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue