Hi Jorge, > It was just an example. I'll have a database recording all the dependencies > for each target. > > > > >> In that case I would need something like the following to be able to > >> invoke the shell commands and update the database with the results. > > > > This would indeed make sense, if the shell commands induce a heavy load. > > It does, say we have to invoke in the order of 10000 gcc commands. My > toy application is a 'make' replacement.
OK > > Yes, I think so too. If I understand you right, you want to call a > > number of shell commands (in a batch list), and then store the results > > in a database. If so, you could use something like that: > > Not exactly, I would prefer not to compose that list in advance. Would > be good to be able to keep queueing commands while previous commands are > running. > My guess is that deciding what to execute next will be time-consuming, > as soon as it can be determined that a target is ready for execution its > command should be queued. I think you can do that easily by with 'fifo', using a global '*Batch' variable instead of the 'Batch' parameter in > > (de processJobs (CPUs Batch) > I guess an additional step is needed that performs the equivalent of > my "waitJobs": Right. This was missing. The remaining running jobs must be waited for. Taking all that into account, I propose the following solution: We install a background 'task', which runs, say, every 2 seconds, and handles all that. We use a global '*Batch' to hold the queue: # *Batch (task -2000 0 # Run once every 2 sec Slots (need 4 "free") # QuadCore (map '((Pos) (cond ((== "free" (car Pos)) # Found a free slot (when (fifo '*Batch) # Any jobs? (set Pos "busy") # Yes (later Pos (eval @)) ) ) ((n== "busy" (car Pos)) # Found a result (msg (car Pos)) # Handle result (ifn (fifo '*Batch) # More jobs? (set Pos "free") # No (set Pos "busy") # Yes (later Pos (eval @)) ) ) ) ) Slots ) ) It checks the slots every 2 seconds, starts new processes when a free slot is found, and handles the results if any are available. We can use 'fifo' to batch a new job: (fifo '*Batch '(call "cc" ..)) : (for X 10 (fifo '*Batch (list '* X X))) -> (* 10 10) : 1 4 9 16 25 36 49 64 81 100 Cheers, - Alex -- UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe