From df28afb19a10c804cd02696bd94b09fed1719478 Mon Sep 17 00:00:00 2001 From: Andrew Stitcher Date: Fri, 18 Apr 2008 21:03:49 +0000 Subject: Refactored Acceptor code to allow multiple acceptors to be present in the broker git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@649689 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/src/qpid/Plugin.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'cpp/src/qpid/Plugin.cpp') diff --git a/cpp/src/qpid/Plugin.cpp b/cpp/src/qpid/Plugin.cpp index d38b53a56e..77627c3742 100644 --- a/cpp/src/qpid/Plugin.cpp +++ b/cpp/src/qpid/Plugin.cpp @@ -22,11 +22,20 @@ namespace qpid { -Plugin::Plugins Plugin::plugins; +namespace { +// This is a single threaded singleton implementation so +// it is important to be sure that the first use of this +// singleton is when the program is still single threaded +Plugin::Plugins& thePlugins() { + static Plugin::Plugins plugins; + + return plugins; +} +} Plugin::Plugin() { // Register myself. - plugins.push_back(this); + thePlugins().push_back(this); } Plugin::~Plugin() {} @@ -34,7 +43,7 @@ Plugin::~Plugin() {} Options* Plugin::getOptions() { return 0; } const Plugin::Plugins& Plugin::getPlugins() { - return plugins; + return thePlugins(); } } // namespace qpid -- cgit v1.2.1