Responder: Difference between revisions
Jump to navigation
Jump to search
Steve Linden (talk | contribs) No edit summary |
Tofu Linden (talk | contribs) mNo edit summary |
||
| Line 1: | Line 1: | ||
* A '''Responder''' is a simple abstraction for handling callbacks that have data associated with them. | * A '''Responder''' is a simple abstraction for handling callbacks that have data associated with them. | ||
* The responder has two | * The responder has two essential properties: | ||
** It is ref counted so that it gets destroyed when both the responder and the respondee are finished with it | ** It is ref counted so that it gets destroyed when both the responder and the respondee are finished with it | ||
** It has a virtual 'completed' function that is called by the responder and implemented by the respondee | ** It has a virtual 'completed' function that is called by the responder and implemented by the respondee | ||
Latest revision as of 06:30, 28 March 2007
- A Responder is a simple abstraction for handling callbacks that have data associated with them.
- The responder has two essential properties:
- It is ref counted so that it gets destroyed when both the responder and the respondee are finished with it
- It has a virtual 'completed' function that is called by the responder and implemented by the respondee
- Simple example:
class LLResponder : public LLThreadSafeRefCount
{
public:
virtual ~LLResponder();
virtual void completed(bool success) = 0;
};
class MyResponder : public LLResponder; // contains private data and overrides completed()
make_a_request("foo", new MyResponder(mydata)}; // when the request completes, MyResponder::completed() will get called