Responder
Jump to navigation
Jump to search
- 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