Processing sequential list of items remotely and asynchronously


During some processing I obtain a list of items that have to be processed one after another on a server. I need to send each item to the server and continue processing, and then upon receiving notification (a call back) that the item’s processing has completed, i can send the next one.

I wonder, what the pattern in prolog is to do that.

Right now used a forall “loop” which, however, is incorrect, since i have to wait for an event for each next items to be processed.

One simple approach would be to temporarily persist the list of items into a queue (e.g. via assert), and then upon receiving of an event, to fetch the next item in the persistent queue.

Would this be also the preferred way to do this.

any thoughts are much appreciated,


Just noticed that I had an algorithmic error here … i need to rethink this a bit more.