> What about box-cas! ?
You might find it handy to use box-cas! via a "swap" style wrapper,
such as box-swap! from rackjure/utils:
(define (box-swap! box f . args)
(let loop ()
(let* ([old (unbox box)]
[new (apply f old args)])
(if (box-cas! box old new)
new
Ahh, my ssh key for localhost was causing the problem because of my use of
tunnels. Correcting the offending key let the example work. [I'm still not
out of the woods but further questions under a different thread.] Thanks!
--
You received this message because you are subscribed to the Googl
I tried it and got the same thing with Linux and Racket 6.1. I did
notice that in the terminal that I started DrRacket from, it was asking
for a password, like it was trying to ssh to localhost.
Not sure how to fix that (public keys maybe?) but hopefully that helps.
Thanks,
Dave
On 09/01/20
If you use thread cells you can avoid global state and synchronization
entirely to solve this problem. Just put a list in the thread cell and add
elements for children threads and increment the head element when new
threads are created.
Robby
On Thursday, September 1, 2016, Erich Rast wrote:
>
Did you look at using a semaphore? That's what I would try, but I also
didn't know about box-cas!
Thanks,
Dave
On 09/01/2016 10:49 AM, Erich Rast wrote:
Wow, I didn't know about box-cas! That seems to be a good solution in
this case. Thanks!
-- Erich
On Thu, 1 Sep 2016 09:37:06 -0300
Gust
I'm encountering the same problem as Matt was. Any help on that? [racket 6.6
on Ubuntu 14.04 and 16.04 (fails on both)]
Incidentally, if I change "localhost" in the spawn-remote-racket-node to some
other host, the example seems to work correctly.
This points to my more general problem. I hav
Wow, I didn't know about box-cas! That seems to be a good solution in
this case. Thanks!
-- Erich
On Thu, 1 Sep 2016 09:37:06 -0300
Gustavo Massaccesi wrote:
> What about box-cas! ?
> https://docs.racket-lang.org/reference/boxes.html#%28def._%28%28quote._~23~25kernel%29._box-cas%21%29%29
>
> S
What about box-cas! ?
https://docs.racket-lang.org/reference/boxes.html#%28def._%28%28quote._~23~25kernel%29._box-cas%21%29%29
Something like:
;---
#lang racket
(define handle-counter (box 1))
(define (new-handle)
(define old (unbox handle-counter))
(define new (add1 old))
(unless (box-cas!
How about using channels:
#lang racket
(define handle-channel (make-channel))
(define (handle-producer ch)
(let loop ((counter 1))
(channel-put ch counter)
(loop (add1 counter
(thread (lambda () (handle-producer handle-channel)))
(define (new-handle)
(channel-get handle-channel
This question is also about style. Take an admittedly ugly
counter like this
;; increasing counter for handles
(define handle-counter 1)
(define (new-handle)
(begin0
handle-counter
(set! handle-counter (add1 handle-counter
Various threads may call (new-handle) concurrently, so I ne
10 matches
Mail list logo