Re: Dataflow variables
Jan Wielemaker <[email protected]>
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
On 11/03/2013 04:50 PM, Aleksey wrote: > Hi guys > > I'm curious what is the easiest way to imitate dataflow variables in Swi-Prolog > My current idea is something like this (pseudocode): > > wait_for(X) :- > freeze(X, awake_this_thread), > suspend_this_thread. One problem here is that threads share terms nor variables. The only ways to talk to each other is by using shared dynamic predicates or message queues. Some systems (e.g., Ciao) have the ability to suspend on clauses being added to a dynamic predicate. That is easy enough to implement. I guess this would mean we have to revert to the immediate update model for such predicates though. Never studied this facility in enough detail. Sharing variables (and terms) between threads would be interesting, but requires a quite different design. Cheers --- Jan > > test :- > do_work_in_separate_thread(Results), > wait_for(Results), > write(Results). > > I'm also interested if there is a way to make those predicates/functions that > require some of their inputs to be bound to execute to automatically suspend > until corresponding variables are bound, e.g.: > > test :- > bind_X_in_separate_thread_after_long_calculation(X), > Y is X+1, > write(X). > > (here I expect for "Y is X+1" to suspend until X gets bound). > -------------- next part -------------- > HTML attachment scrubbed and removed > _______________________________________________ > SWI-Prolog mailing list > [email protected] > https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog >