chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] poll(2) with chicken: works - sort of


From: Jörg F . Wittenberger
Subject: Re: [Chicken-hackers] poll(2) with chicken: works - sort of
Date: 15 May 2012 12:20:56 +0200

Hi John,

well the implementation is messy and the API as I mentioned
is the intended idea.

I'll attach the messy code.  But when reading it, please
swap "!map" for "map-parallel" - each of them does what
the other should.  Just it's one more change to my code
base to be done....

I'm still experimenting with how exactly parameters like
timeouts should be passed to "!map" for instance.

Here an usage example:

(lambda (source quorum local target)
    (!mapfold
;; map this for each host
     (lambda (voter)
        (let ((addr ((host-lookup) voter)))
          (if voter
              (let ((reply (http-get-privileges source addr local target)))
                (parse-capability-statement (message-body reply)))
              (raise-service-unavailable-condition voter))))
;; the KONS: combine the result and "i";
;; by modifying "n", the accumulation process could be terminated
;; earlier (it's the number of pending elements)
     (lambda (n result i)
(values n (fold (lambda (e i1) (if (member e i) i1 (cons e i1))) i result))) ;; the initial value for the FOLD operation
     '()
;; the input (list) to map over
     quorum
;; count #t means: count all or up to timeout
     count: #t
     timeout: (respond-timeout-interval)
))



On May 14 2012, John Cowan wrote:

Jörg F. Wittenberger scripsit:

[1]:  I'm using e.g. "!apply", "!map" and "!mapfold" where
!apply would create and immediately join (possibly with
timeout) a thread to apply the function to it's arguments.
!map does what map does, just one thread per element in paralles
and !mapfold accumulates the results in unspecified order
(as available) possibly only waiting for an specified number of
map results to become available.

Can you provide more details?  This looks like a very interesting
API indeed.  Thanks.


Attachment: parallel.scm
Description: parallel.scm


reply via email to

[Prev in Thread] Current Thread [Next in Thread]