diff options
| author | Alan Conway <aconway@apache.org> | 2014-01-27 20:09:25 +0000 |
|---|---|---|
| committer | Alan Conway <aconway@apache.org> | 2014-01-27 20:09:25 +0000 |
| commit | b710193d135c55357d3333bd55a733a49c361632 (patch) | |
| tree | e8d357a0687a1b711577ff01a5608b37b14c3504 /qpid/cpp/src/qpid/ha/PrimaryTxObserver.cpp | |
| parent | ecf1ea9d93ffc84ee758efdd89fa2749e3ec7aa7 (diff) | |
| download | qpid-python-b710193d135c55357d3333bd55a733a49c361632.tar.gz | |
NO-JIRA: Minor refactor to improve code safety: calling shared_from_this on creation.
Previous anti-pattern: Classes need to call shared_from_this during creation,
but can't call it in the ctor so had a separate initiailize function that the
user was required to call immediately after the constructor. Possible for user
to forget.
Improved pattern: Introduce public static create() functions to call constructor
and initialize, make constructor and initialize private.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1561828 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src/qpid/ha/PrimaryTxObserver.cpp')
| -rw-r--r-- | qpid/cpp/src/qpid/ha/PrimaryTxObserver.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/qpid/cpp/src/qpid/ha/PrimaryTxObserver.cpp b/qpid/cpp/src/qpid/ha/PrimaryTxObserver.cpp index eeb3312aec..dc5bf15911 100644 --- a/qpid/cpp/src/qpid/ha/PrimaryTxObserver.cpp +++ b/qpid/cpp/src/qpid/ha/PrimaryTxObserver.cpp @@ -82,6 +82,14 @@ class PrimaryTxObserver::Exchange : public broker::Exchange { const string PrimaryTxObserver::Exchange::TYPE_NAME(string(QPID_HA_PREFIX)+"primary-tx-observer"); +boost::shared_ptr<PrimaryTxObserver> PrimaryTxObserver::create( + Primary& p, HaBroker& hb, const boost::intrusive_ptr<broker::TxBuffer>& tx) { + boost::shared_ptr<PrimaryTxObserver> pto(new PrimaryTxObserver(p, hb, tx)); + pto->initialize(); + return pto; +} + + PrimaryTxObserver::PrimaryTxObserver( Primary& p, HaBroker& hb, const boost::intrusive_ptr<broker::TxBuffer>& tx ) : |
