I saw that function, but was scared off by its documentation:

Like semaphore-wait, but semaphore-try-wait? never blocks execution. If sema’s 
internal counter is zero, semaphore-try-wait? returns #f immediately 
without decrementing the counter. If sema’s counter is positive, it is 
decremented and #t is returned.

I'm not sure why I'd want it to decrement the count, I really just want to 
see if my critical section is running. I will try it though, thanks.

On Tuesday, 4 September 2018 13:17:09 UTC+1, Matthew Flatt wrote:
>
> There's no `semaphore-count`, but you can use `semaphore-try-wait?` to 
> poll a semaphore instead of blocking. 
>
> At Tue, 4 Sep 2018 04:47:46 -0700 (PDT), Craig Allen wrote: 
> > So I have this snippet pinched from Rosetta Code: 
> > 
> > (define-syntax-rule (define/atomic (name arg ...) body ...) 
> >   (define name 
> >     (let ([sema (make-semaphore 1)]) 
> >       (lambda (arg ...) 
> >         (dynamic-wind (lambda () (semaphore-wait sema)) 
> >                       (lambda () body ...) 
> >                       (lambda () (semaphore-post sema))))))) 
> > 
> > But I would like to be able to ask whether I will have to wait, before I 
> am 
> > in fact waiting (so I can print a message). I notice the fsemaphore 
> package 
> > exports semaphore-count, but semaphore does not. Is this an oversight, 
> or 
> > is there a better way to do this? 
> > 
> > Thanks, 
> > 
> > Craig 
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to