[asterisk-scf-commits] asterisk-scf/release/media_operations_core.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Fri Sep 30 13:28:02 CDT 2011
branch "master" has been updated
via f652a95e1599540c3eeabc71046a2df1e597d598 (commit)
from 4f1d6bb50856993502dba2b38e9c0851093f8fed (commit)
Summary of changes:
src/CMakeLists.txt | 2 +-
src/MediaOperationsCore.cpp | 98 +++++--------------------------------------
2 files changed, 12 insertions(+), 88 deletions(-)
- Log -----------------------------------------------------------------
commit f652a95e1599540c3eeabc71046a2df1e597d598
Author: Kevin P. Fleming <kpfleming at digium.com>
Date: Fri Sep 30 13:27:25 2011 -0500
Use AsteriskSCF::PJLib::ThreadHook for tracking threads created by the
Ice runtime.
Review: https://code.asterisk.org/code/cru/CR-ASTSCF-168
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 8fb6d1f..d4b15f4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -31,7 +31,7 @@ astscf_component_add_slices(MediaOperationsCore PROJECT AsteriskSCF/Replication/
astscf_component_add_slice_collection_libraries(MediaOperationsCore ASTSCF)
astscf_component_add_boost_libraries(MediaOperationsCore core thread date_time)
astscf_component_build_icebox(MediaOperationsCore)
-target_link_libraries(MediaOperationsCore logging-client astscf-ice-util-cpp)
+target_link_libraries(MediaOperationsCore logging-client astscf-ice-util-cpp astscf-ice-util-cpp-pjlib)
pjproject_link(MediaOperationsCore pjlib)
pjproject_link(MediaOperationsCore pjlib-util)
diff --git a/src/MediaOperationsCore.cpp b/src/MediaOperationsCore.cpp
index 7c80d67..edaec40 100644
--- a/src/MediaOperationsCore.cpp
+++ b/src/MediaOperationsCore.cpp
@@ -19,6 +19,7 @@
#include <AsteriskSCF/Component/Component.h>
#include <AsteriskSCF/Media/MediaOperationIf.h>
+#include <AsteriskSCF/PJLib/ThreadHook.h>
#include <AsteriskSCF/logger.h>
#include "MediaOperationReplicationContext.h"
@@ -96,83 +97,6 @@ private:
typedef IceUtil::Handle<MediaOperationsCompare> MediaOperationsComparePtr;
-/**
- * Wrapper class around pj_thread_desc.
- */
-class ThreadDescWrapper
-{
-public:
- ThreadDescWrapper()
- {
- memset(mDesc, 0, sizeof(mDesc));
- }
-
- /**
- * pjthread thread description information, must persist for the life of the thread
- */
- pj_thread_desc mDesc;
-};
-
-/**
- * Type definition used to create a smart pointer for the above.
- */
-typedef boost::shared_ptr<ThreadDescWrapper> ThreadDescWrapperPtr;
-
-//XXX Seriously how many places is this repeated?
-/**
- * Implementation of the Ice::ThreadNotification class.
- */
-class pjlibHook : public Ice::ThreadNotification
-{
-public:
- pjlibHook()
- {
- pj_init();
- }
-
- /**
- * Implementation of the start function which is called when a thread starts.
- */
- void start()
- {
- ThreadDescWrapperPtr wrapper(new ThreadDescWrapper());
- pj_thread_t *thread;
- pj_status_t win = pj_thread_register("ICE Thread", wrapper->mDesc, &thread);
- if (win != PJ_SUCCESS)
- {
- lg(Critical) << "Unable to register thread with PJLIB.";
- return;
- }
- else
- {
- boost::lock_guard<boost::mutex> lock(mLock);
- mpjThreads.insert(std::make_pair(thread, wrapper));
- }
- }
-
- /**
- * Implementation of the stop function which is called when a thread stops.
- */
- void stop()
- {
- if (pj_thread_is_registered())
- {
- boost::lock_guard<boost::mutex> lock(mLock);
- mpjThreads.erase(pj_thread_this());
- }
- }
-
-private:
- /**
- * A map containing thread lifetime persistent data.
- */
- std::map<pj_thread_t*, ThreadDescWrapperPtr> mpjThreads;
- /**
- * Mutex to protect the map
- */
- boost::mutex mLock;
-};
-
class MediaOperationsComponent : public AsteriskSCF::Component::Component
{
public:
@@ -197,7 +121,7 @@ private:
factory->setProxy(factoryProxy);
mFactories.push_back(std::make_pair(factory, factoryProxy));
}
-
+
void createOperationFactories()
{
lg(Debug) << "Creating UlawAlawFactory";
@@ -228,7 +152,7 @@ private:
try
{
AsteriskSCF::Discovery::SmartProxy<MediaOperationStateReplicatorPrx> pw(getServiceLocator(), params, lg);
- MediaOperationReplicationContextPtr context =
+ MediaOperationReplicationContextPtr context =
boost::static_pointer_cast<MediaOperationReplicationContext>(getReplicationContext());
context->setReplicator(pw);
@@ -257,19 +181,19 @@ private:
iter->first->getName(),
iter->first->getLocatorParams(),
iter->first->getName()));
-
+
managePrimaryService(wrapper);
}
}
// Below are overrides of the base component class.
-
+
void onPreInitialize()
{
try
{
Ice::InitializationData id;
- id.threadHook = new pjlibHook();
+ id.threadHook = new AsteriskSCF::PJLib::ThreadHook("Ice");
id.properties = getCommunicator()->getProperties();
setCommunicator(Ice::initialize(id));
@@ -320,7 +244,7 @@ private:
MediaOperationStateReplicatorListenerPrx replicatorListener =
MediaOperationStateReplicatorListenerPrx::uncheckedCast(getBackplaneAdapter()->addWithUUID(mReplicatorListener));
-
+
mReplicatorListenerProxy = MediaOperationStateReplicatorListenerPrx::uncheckedCast(replicatorListener->ice_oneway());
}
@@ -340,7 +264,7 @@ private:
}
try
- {
+ {
if (context->getState() == STANDBY_IN_REPLICA_GROUP)
{
context->getReplicator()->addListener(mReplicatorListenerProxy);
@@ -356,14 +280,14 @@ private:
void stopListeningToStateReplicators()
{
- MediaOperationReplicationContextPtr context =
+ MediaOperationReplicationContextPtr context =
boost::static_pointer_cast<MediaOperationReplicationContext>(getReplicationContext());
-
+
if ((!context->getReplicator().isInitialized()) || (mListeningToReplicator == false))
{
return;
}
-
+
try
{
context->getReplicator()->removeListener(mReplicatorListenerProxy);
-----------------------------------------------------------------------
--
asterisk-scf/release/media_operations_core.git
More information about the asterisk-scf-commits
mailing list