|
Boost Users : |
From: Khandelwal, Amit (amit.khandelwal_at_[hidden])
Date: 2008-07-16 14:37:48
If I am able to understand your problem correctly sounds like you want
to use active object pattern.
http://en.wikipedia.org/wiki/Active_Object
http://www.cs.wustl.edu/~schmidt/PDF/Act-Obj.pdf
ACE has support for that not sure if boost has it.
-----Original Message-----
From: boost-users-bounces_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]] On Behalf Of Igor R
Sent: Wednesday, July 16, 2008 2:18 PM
To: boost-users_at_[hidden]
Subject: [Boost-users] [boost-users][bind, signal] how to
Hello,
I've got the following design: several functors ("Tasks"), when
executed, "delegate" to a shared Processor object that performs some
coordination between the tasks. The Processor runs the tasks at some
stage, and wants to be notified by the task when it's over.
However, I wouldn't like them to "know" each other. I even wouldn't like
the Processor making assumptions about exact Task's "connection point"
signature/name.
For this purpose I want the Task to pass its "connection point" as a
generic functor - so that the Processor would execute it to subscribe.
However, I haven't managed to bind signal::connect. I'd appreciate any
idea about what's wrong in the following schematic code:
(In the real code the life-time of the objects is managed by means of
shared/weak pointers, which are omitted here for the sake of
simplicity!)
//task.hpp
class Task
{
public:
typedef signal<void (void)> CompletionEvent;
void operator ()()
{
// forward the execution to the processor;
(*processor)(bind(&Task::run, this),
bind(&CompetionEvent::connect, &done_, _1)); // this bind dosen't
compile!
}
private:
void run();
Processor *processor_;
signal<void(void)> done_;
};
// processor.hpp
class Processor
{
public:
void operator ()(boost::function<void(void)> task,
boost::function<void(boost::function<void(void)>)>
completionNotifier)
{
// this way I'd like to call
signal::connect(bind(&Processor::taskDone, this));
completionNotifier(bind(&Processor::taskDone, this));
}
private:
void taskDone();
};
Thank you!
_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice.
--------
IRS Circular 230 Disclosure:
Please be advised that any discussion of U.S. tax matters contained within this communication (including any attachments) is not intended or written to be used and cannot be used for the purpose of (i) avoiding U.S. tax related penalties or (ii) promoting, marketing or recommending to another party any transaction or matter addressed herein.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net