sync: accept 0 arguments
As suggested by Jonathan Schuster. Note that the `choice-evt` constructor already accepted 0 arguments.
This commit is contained in:
parent
3cab3f1000
commit
df5bfe19c0
|
@ -51,7 +51,7 @@ Returns @racket[#t] if @racket[v] is a @tech{synchronizable event},
|
|||
]}
|
||||
|
||||
|
||||
@defproc[(sync [evt evt?] ...+) any]{
|
||||
@defproc[(sync [evt evt?] ...) any]{
|
||||
|
||||
Blocks as long as none of the @tech{synchronizable events}
|
||||
@racket[evt]s are ready, as defined above.
|
||||
|
@ -67,11 +67,13 @@ random-number generator that controls this choice.
|
|||
(define ch (make-channel))
|
||||
(thread (λ () (displayln (sync ch))))
|
||||
(channel-put ch 'hellooooo)
|
||||
]}
|
||||
]
|
||||
|
||||
@history[#:changed "6.1.0.3" @elem{Allow 0 arguments instead of 1 or more.}]}
|
||||
|
||||
|
||||
@defproc[(sync/timeout [timeout (or/c #f (and/c real? (not/c negative?)) (-> any))]
|
||||
[evt evt?] ...+)
|
||||
[evt evt?] ...)
|
||||
any]{
|
||||
|
||||
Like @racket[sync] if @racket[timeout] is @racket[#f]. If
|
||||
|
@ -95,10 +97,12 @@ See also @racket[alarm-evt] for an alternative timeout mechanism.
|
|||
(sync/timeout
|
||||
(λ () (displayln "no ready events"))
|
||||
never-evt)
|
||||
]}
|
||||
]
|
||||
|
||||
@history[#:changed "6.1.0.3" @elem{Allow 1 argument instead of 2 or more.}]}
|
||||
|
||||
|
||||
@defproc[(sync/enable-break [evt evt?] ...+) any]{
|
||||
@defproc[(sync/enable-break [evt evt?] ...) any]{
|
||||
|
||||
Like @racket[sync], but breaking is enabled (see
|
||||
@secref["breakhandler"]) while waiting on the @racket[evt]s. If
|
||||
|
@ -108,7 +112,7 @@ exception is raised, but not both.}
|
|||
|
||||
|
||||
@defproc[(sync/timeout/enable-break [timeout (or/c #f (and/c real? (not/c negative?)) (-> any))]
|
||||
[evt evt?] ...+)
|
||||
[evt evt?] ...)
|
||||
any]{
|
||||
|
||||
Like @racket[sync/enable-break], but with a timeout as for @racket[sync/timeout].}
|
||||
|
|
|
@ -1373,4 +1373,18 @@
|
|||
|
||||
;; ----------------------------------------
|
||||
|
||||
;; zero-argument case:
|
||||
(test #f sync/timeout 0)
|
||||
(test #f sync
|
||||
(handle-evt (system-idle-evt)
|
||||
(lambda (_) #f))
|
||||
(thread (lambda () (sync))))
|
||||
|
||||
(let ([t (thread (lambda () (with-handlers ([exn:break? void]) (sync))))])
|
||||
(sync (system-idle-evt))
|
||||
(break-thread t)
|
||||
(test t sync t))
|
||||
|
||||
;; ----------------------------------------
|
||||
|
||||
(report-errs)
|
||||
|
|
|
@ -604,10 +604,10 @@ void scheme_init_thread(Scheme_Env *env)
|
|||
|
||||
|
||||
GLOBAL_FOLDING_PRIM("evt?" , evt_p , 1, 1 , 1, env);
|
||||
GLOBAL_PRIM_W_ARITY2("sync" , sch_sync , 1, -1, 0, -1, env);
|
||||
GLOBAL_PRIM_W_ARITY2("sync/timeout" , sch_sync_timeout , 2, -1, 0, -1, env);
|
||||
GLOBAL_PRIM_W_ARITY2("sync/enable-break" , sch_sync_enable_break , 1, -1, 0, -1, env);
|
||||
GLOBAL_PRIM_W_ARITY2("sync/timeout/enable-break", sch_sync_timeout_enable_break, 2, -1, 0, -1, env);
|
||||
GLOBAL_PRIM_W_ARITY2("sync" , sch_sync , 0, -1, 0, -1, env);
|
||||
GLOBAL_PRIM_W_ARITY2("sync/timeout" , sch_sync_timeout , 1, -1, 0, -1, env);
|
||||
GLOBAL_PRIM_W_ARITY2("sync/enable-break" , sch_sync_enable_break , 0, -1, 0, -1, env);
|
||||
GLOBAL_PRIM_W_ARITY2("sync/timeout/enable-break", sch_sync_timeout_enable_break, 1, -1, 0, -1, env);
|
||||
GLOBAL_PRIM_W_ARITY("choice-evt" , evts_to_evt , 0, -1, env);
|
||||
|
||||
GLOBAL_PARAMETER("current-thread-initial-stack-size", current_thread_initial_stack_size, MZCONFIG_THREAD_INIT_STACK_SIZE, env);
|
||||
|
|
Loading…
Reference in New Issue
Block a user