[Top][All Lists]

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

Re: About 'futures'

From: Rob Browning
Subject: Re: About 'futures'
Date: Tue, 08 Mar 2005 15:37:36 -0600
User-agent: Gnus/5.1007 (Gnus v5.10.7) Emacs/21.3 (gnu/linux)

Marius Vollmer <address@hidden> writes:

> what is the difference between
>     (join-thread (begin-thread (foo)))
> and
>     (future-ref (future (foo)))
> I am thinking about implementing futures as just
>     (define-macro (future exp) `(begin-thread ,exp))
>     (define future-ref join-thread)
> Would that make sense?

Based on what I know of the semantics of the respective operations, it
seems fine.

Though is a terminated thread very "heavy"?  i.e. is it much heavier
than a cons pair?  If so, then one optimization for futures would be
to implement them such that when the thread is finished, the thread
pointer is dropped, so that only the result remains.

One way to do that might be to represent a future as (cons thread
result-destination).  Given that, future-ref would either join-thread
or call cdr as appropriate.  Although you'd probably also need a mutex
which might obviate any potential resource savings achieved by
dropping the thread.

Rob Browning
rlb and; previously
GPG starting 2002-11-03 = 14DD 432F AE39 534D B592  F9A0 25C8 D377 8C7E 73A4

reply via email to

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