Boost logo

Boost :

From: Hurd, Matthew (hurdm_at_[hidden])
Date: 2004-02-23 19:00:16


> On Behalf Of Matthew Vogt
> Subject: [boost] Re: [Threads] Simple active object wrapper, take 2
>
> > scott <scottw <at> qbik.com> writes:
>

Had a little thought that might be relevant. Please spank me if this is
OT given the rather specific implementation I'm dropping in on...

As mentioned previously, future values could give you a lazy way of
evaluating the result, even when you aren't multithreaded.

In the truly "active" object, that is, it has at least one thread, you
could call the methods with a future instead of a normal value so that
when the result arrives it percolates through the implied queue.

Now for a new thought. What about using an expression template
mechanism so that when you combine futures they are glommed at compile
time to remain lazy?

boost::future<double> sum = some_thing_maybe_active.total();
boost::future<double> count = some_thing_maybe_active.count();
boost::future<double> average = sum / count;

sum / count forms a lazy expression

if a method groks a future and then this becomes interesting...

boost::future<double> result =
some_thing_maybe_active.do_stuff(average);

You can end up with the active object percolating all the way through to
"result" without any blocking until the result of "result" is used.

If you get rid of the thread(s) in the active object idea, you end up
with a mechanism for lazy evaluation.

Perhaps there is a more general mechanism / pattern and bike shop name
lurking in this pattern...

Regards,

Matt Hurd
_______________________

Susquehanna Pacific P/L
hurdm_at_[hidden]
+61.2.8226.5029
_______________________

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk