[asterisk-scf-commits] asterisk-scf/integration/sip.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Mon Aug 23 13:58:22 CDT 2010
branch "master" has been updated
via 86577567d70f7680a1907428d7a0d3058db3b71e (commit)
from 337d252631934a48399d4e74ed56a7604da36135 (commit)
Summary of changes:
src/SipChannelServiceApp.cpp | 57 ++++++++++++++++++++++++++++++++++++++++-
1 files changed, 55 insertions(+), 2 deletions(-)
- Log -----------------------------------------------------------------
commit 86577567d70f7680a1907428d7a0d3058db3b71e
Author: Joshua Colp <jcolp at digium.com>
Date: Mon Aug 23 16:12:57 2010 -0300
Add ICE threads to pjlib so we can call pj* functions within ICE threads without any qualms.
diff --git a/src/SipChannelServiceApp.cpp b/src/SipChannelServiceApp.cpp
index daa9ebf..11b5f66 100644
--- a/src/SipChannelServiceApp.cpp
+++ b/src/SipChannelServiceApp.cpp
@@ -4,6 +4,8 @@
#include <boost/thread.hpp>
#include <boost/shared_ptr.hpp>
+#include <pjlib.h>
+
#include "RoutingIf.h"
#include "ServiceLocatorIf.h"
#include "ComponentServiceIf.h"
@@ -155,6 +157,55 @@ private:
};
/**
+ * Wrapper class around pj_thread_desc.
+ */
+class ThreadDescWrapper
+{
+public:
+ /**
+ * 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;
+
+/**
+ * Implementation of the Ice::ThreadNotification class.
+ */
+class pjlibHook : public Ice::ThreadNotification
+{
+public:
+ /**
+ * Implementation of the start function which is called when a thread starts.
+ */
+ void start()
+ {
+ ThreadDescWrapperPtr wrapper = ThreadDescWrapperPtr(new ThreadDescWrapper());
+ pj_thread_t *thread;
+ pj_thread_register("ICE Thread", wrapper->mDesc, &thread);
+ pjThreads.insert(make_pair(thread, wrapper));
+ }
+
+ /**
+ * Implementation of the stop function which is called when a thread stops.
+ */
+ void stop()
+ {
+ pjThreads.erase(pj_thread_this());
+ }
+
+private:
+ /**
+ * A map containing thread lifetime persistent data.
+ */
+ map<pj_thread_t*, ThreadDescWrapperPtr> pjThreads;
+};
+
+/**
* Handles control characters in case the component is invoked as a console app.
*/
void SipChannelServiceApp::interruptCallback(int val)
@@ -354,7 +405,9 @@ static SipChannelServiceApp app;
// Application entry point.
int main(int argc, char* argv[])
{
- app.callbackOnInterrupt();
- return app.main(argc, argv);
+ app.callbackOnInterrupt();
+ Ice::InitializationData id;
+ id.threadHook = new pjlibHook();
+ return app.main(argc, argv, id);
}
-----------------------------------------------------------------------
--
asterisk-scf/integration/sip.git
More information about the asterisk-scf-commits
mailing list