Re: [racket-users] Semaphore-count

2018-09-07 Thread Craig Allen
Thanks, I will look into this. On Thursday, 6 September 2018 03:25:43 UTC+1, gneuner2 wrote: > > > On 9/4/2018 11:46 AM, George Neuner wrote: > > > > AFAIK there is no way to simply 'check' if the semaphore is available. > > > > I was wrong - there is a way using events: semaphore-peek-evt c

Re: [racket-users] Semaphore-count

2018-09-05 Thread George Neuner
On 9/4/2018 11:46 AM, George Neuner wrote: AFAIK there is no way to simply 'check' if the semaphore is available. I was wrong - there is a way using events: semaphore-peek-evt  can check whether a semaphore is ready without affecting its counter. https://docs.racket-lang.org/reference/se

RE: [racket-users] Semaphore-count

2018-09-05 Thread Jos Koot
post count) (make-sema 3)) (count) (wait) (count) (post) (count) _ From: racket-users@googlegroups.com [mailto:racket-users@googlegroups.com] On Behalf Of George Neuner Sent: 04 September 2018 17:47 To: Craig Allen Cc: racket users Subject: Re: [racket-users] Semaphore-count On 9/4

Re: [racket-users] Semaphore-count

2018-09-04 Thread George Neuner
On 9/4/2018 8:31 AM, Craig Allen wrote: 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

Re: [racket-users] Semaphore-count

2018-09-04 Thread Craig Allen
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 an

Re: [racket-users] Semaphore-count

2018-09-04 Thread Matthew Flatt
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