summaryrefslogtreecommitdiff
path: root/tubes/source
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2012-03-23 16:39:43 +0000
committerMatúš Kukan <matus.kukan@gmail.com>2012-07-17 16:39:56 +0200
commit0dae49a03c9b4816d8cdde69e30bcd2db2e30724 (patch)
treee27f8759d133152608a45017f2591730a9c5bab5 /tubes/source
parentc72addf2d5445a86be5307c306002565b43f4dcb (diff)
tubes: add a shared TeleManager singleton
Yes, this is in addition to the existing TeleManagerImpl singleton. This class needs to be properly split in half: one Manager part from which the UI can request new sessions and which signals the appearance of new incoming sessions, and another Session part representing the shared editing session (which in turn owns one or more Conferences, which owns exactly one tube, as now). The Manager will dispatch incoming files to the appropriate Conference by UUID or similar. But for now, Michael is opening a new window with the received file, so we want incoming and outgoing events to go to both windows so that it works well enough for a demo.
Diffstat (limited to 'tubes/source')
-rw-r--r--tubes/source/manager.cxx36
1 files changed, 36 insertions, 0 deletions
diff --git a/tubes/source/manager.cxx b/tubes/source/manager.cxx
index 088080d7f1bd..e0e242574bda 100644
--- a/tubes/source/manager.cxx
+++ b/tubes/source/manager.cxx
@@ -70,6 +70,9 @@ TeleManagerImpl* TeleManager::pImpl = NULL;
sal_uInt32 TeleManager::nRefCount = 0;
rtl::OString TeleManager::aNameSuffix;
+sal_uInt32 TeleManager::nAnotherRefCount = 0;
+TeleManager* TeleManager::pSingleton = NULL;
+
/** Refcounted singleton implementation class. */
class TeleManagerImpl
@@ -386,6 +389,27 @@ TeleManager::~TeleManager()
}
}
+TeleManager *
+TeleManager::get()
+{
+ MutexGuard aGuard( GetAnotherMutex());
+ if (!pSingleton)
+ pSingleton = new TeleManager();
+
+ nAnotherRefCount++;
+ return pSingleton;
+}
+
+void
+TeleManager::unref()
+{
+ MutexGuard aGuard( GetAnotherMutex());
+ if (--nAnotherRefCount == 0) {
+ delete pSingleton;
+ pSingleton = NULL;
+ }
+}
+
bool TeleManager::connect()
{
@@ -931,6 +955,18 @@ Mutex& TeleManager::GetMutex()
return *pMutex;
}
+Mutex& TeleManager::GetAnotherMutex()
+{
+ static Mutex* pMutex = NULL;
+ if (!pMutex)
+ {
+ MutexGuard aGuard( Mutex::getGlobalMutex());
+ if (!pMutex)
+ pMutex = new Mutex;
+ }
+ return *pMutex;
+}
+
// static
void TeleManager::addSuffixToNames( const char* pName )