Re: [Gauche-devel] Implementation of Futures
R7RS Scheme scripting engine
Status: Beta
Brought to you by:
shirok
|
From: Shiro K. <shi...@gm...> - 2023-02-09 09:32:45
|
Hi Glenn, Your feeling is correct. 'future' spawns a new pthread to compute the expression, and "future-get" calls thread-join! to get the result. If you create a bunch of futures, they all run in parallel. If you print something during the computation, the order you'll see the output is indeterministic---the output happens _before_ future-get anyway. If you make check-trees-of-depth return a value, and collect teh values of future-get in a list, you'll see the list is always consistent. Does this answer your question? --shiro On Wed, Feb 8, 2023 at 8:44 PM Glenn Takanishi <gl...@ne...> wrote: > 2023-2-8 > > Hello! > > Just curious about how futures is implemented. A short description would > suffice with respect to some code I was playing with (it's attached to this > email just for fun). > > The Gauche documentation on futures says that "future" calls code in a > separate thread (I assume a Posix pthread). So I get the feeling that a > "future" is like "pthread_create" in C. And that "future-get" can be > likened to "pthread_join". The structure of the programs between Scheme > and C look alike. > > But the output returns after "future-get" is random. The output result > from pthread_join is usally not. This is not a problem for me. I'm just > curious as to why this happens. The behavior using Guile scheme is similar > with random output results from "touch". > > This question might seem weird to you, and I apologize if so. I'm just > curious. Thanks. > > Glenn > > > _______________________________________________ > Gauche-devel mailing list > Gau...@li... > https://lists.sourceforge.net/lists/listinfo/gauche-devel > |