Handbook
Glossary
sleep-time ( -- nanos/f )
Vocabulary
threads
Inputs
None
Outputs
nanos/f
a non-negative integer or
f
Word description
Returns the time until the next sleeping thread is scheduled to wake up, which could be zero if there are threads in the run queue, or threads which need to wake up right now. If there are no runnable or sleeping threads, returns
f
.
Definition
USING:
alien.private
assocs
combinators
deques
heaps
kernel
math.order
system
;
IN:
threads
:
sleep-time
( -- nanos/f )
{
{
[
current-callback
waiting-callbacks
key?
]
[
0
]
}
{
[
run-queue
deque-empty?
not
]
[
0
]
}
{
[
sleep-queue
heap-empty?
]
[
f
]
}
[
sleep-queue
heap-peek
nip
nano-count
[-]
]
}
cond
;