Brian,

I may be jumping in with both feet here; but this is the pattern I’ve
found works for me.


I don’t know if you’ve got all of your workers being fed from a single
input place-channel.

1. create a (response-channel-send response-channel-recv) with 
make-place-channel
2. create a (request-channel-send request-channel-recv) with make-place-channel

Build your worker places; remember them --- but only use their channels for
“control” activities (i.e. “quit“).

Send request-channel-recv and response-channel-send to the worker
(as two messages or a cons or whatever).


Your worker becomes

(thread
(lambda ()
(let loop ()
  (define work-unit (place-channel-get request-channel-recv))
  (place-channel-put response-channel-send (work work-unit))
  (loop)))

Use sync to also listen to your own place for control.

The workers will consume as fast as they can; or block if they’re not
fed.

The server can aggregate the results from response-channel-recv; again
as fast as.


If the server uses a semaphore to semaphore-get before doing a worker post;
and semaphore-put when doing a response read -- then it can be choked to
only loading the request-channel-send channel to whatever the semaphore
was initialised to (suggest the number of workers * an int?).


You could also look at:
 https://github.com/tim-brown/place-farm/blob/master/place-farm.rkt
but I’ve been doing better things with places since then.

On Thursday, January 21, 2016 at 4:09:32 PM UTC, Brian Adkins wrote:
> I have a better idea of how places work now, but it seems like it would be 
> handy to have a way to limit the size of a place channel, right?  If my input 
> place is running much faster than the worker places, each of the worker place 
> channels may be getting *huge* which seems bad.

Hope that helps.

Tim

-- 
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