Commit 87b61e96 authored by Steven Murray's avatar Steven Murray
Browse files

Moved instantiateZmqContext() to SmartZmqContext

parent 19a5d2ba
......@@ -39,15 +39,6 @@
*/
static int exceptionThrowingMain(const int argc, char *const *const argv);
/**
* Instantiates a ZMQ context.
*
* @param sizeOfIOThreadPoolForZMQ The size of the thread pool used to perform
* IO. This is usually 1 thread.
* @return A pointer to the newly created ZMQ context.
*/
static void *instantiateZmqContext(const int sizeOfIOThreadPoolForZMQ);
//------------------------------------------------------------------------------
// main
//------------------------------------------------------------------------------
......@@ -76,7 +67,6 @@ int main(const int argc, char *const *const argv) {
return 1;
}
//------------------------------------------------------------------------------
// exceptionThrowingMain
//------------------------------------------------------------------------------
......@@ -84,8 +74,8 @@ static int exceptionThrowingMain(const int argc, char *const *const argv) {
using namespace cta;
const int sizeOfIOThreadPoolForZMQ = 1;
mediachanger::SmartZmqContext zmqContext(instantiateZmqContext(
sizeOfIOThreadPoolForZMQ));
mediachanger::SmartZmqContext
zmqContext(mediachanger::SmartZmqContext::instantiateZmqContext(sizeOfIOThreadPoolForZMQ));
mediachanger::AcsProxyZmq acs(mediachanger::ACS_PORT, zmqContext.get());
mediachanger::MmcProxyNotSupported mmc;
......@@ -106,18 +96,3 @@ static int exceptionThrowingMain(const int argc, char *const *const argv) {
return cmd.exceptionThrowingMain(argc, argv);
}
//------------------------------------------------------------------------------
// instantiateZmqContext
//------------------------------------------------------------------------------
static void *instantiateZmqContext(const int sizeOfIOThreadPoolForZMQ) {
using namespace cta;
void *const zmqContext = zmq_init(sizeOfIOThreadPoolForZMQ);
if(NULL == zmqContext) {
const std::string message = utils::errnoToString(errno);
cta::exception::Exception ex;
ex.getMessage() << "Failed to instantiate ZMQ context: " << message;
throw ex;
}
return zmqContext;
}
......@@ -39,15 +39,6 @@
*/
static int exceptionThrowingMain(const int argc, char *const *const argv);
/**
* Instantiates a ZMQ context.
*
* @param sizeOfIOThreadPoolForZMQ The size of the thread pool used to perform
* IO. This is usually 1 thread.
* @return A pointer to the newly created ZMQ context.
*/
static void *instantiateZmqContext(const int sizeOfIOThreadPoolForZMQ);
//------------------------------------------------------------------------------
// main
//------------------------------------------------------------------------------
......@@ -82,7 +73,8 @@ static int exceptionThrowingMain(const int argc, char *const *const argv) {
using namespace cta;
const int sizeOfIOThreadPoolForZMQ = 1;
mediachanger::SmartZmqContext zmqContext(instantiateZmqContext(sizeOfIOThreadPoolForZMQ));
mediachanger::SmartZmqContext
zmqContext(mediachanger::SmartZmqContext::instantiateZmqContext(sizeOfIOThreadPoolForZMQ));
mediachanger::AcsProxyZmq acs(mediachanger::ACS_PORT, zmqContext.get());
mediachanger::MmcProxyNotSupported mmc;
......@@ -103,18 +95,3 @@ static int exceptionThrowingMain(const int argc, char *const *const argv) {
return cmd.exceptionThrowingMain(argc, argv);
}
//------------------------------------------------------------------------------
// instantiateZmqContext
//------------------------------------------------------------------------------
static void *instantiateZmqContext(const int sizeOfIOThreadPoolForZMQ) {
using namespace cta;
void *const zmqContext = zmq_init(sizeOfIOThreadPoolForZMQ);
if(NULL == zmqContext) {
const std::string message = utils::errnoToString(errno);
cta::exception::Exception ex;
ex.getMessage() << "Failed to instantiate ZMQ context: " << message;
throw ex;
}
return zmqContext;
}
......@@ -17,6 +17,7 @@
*/
#include "mediachanger/SmartZmqContext.hpp"
#include "common/utils/utils.hpp"
#include <errno.h>
#include <unistd.h>
......@@ -104,5 +105,18 @@ void *SmartZmqContext::release() {
return tmp;
}
//------------------------------------------------------------------------------
// instantiateZmqContext
//------------------------------------------------------------------------------
void *SmartZmqContext::instantiateZmqContext(const int sizeOfIOThreadPoolForZMQ) {
using namespace cta;
void *const zmqContext = zmq_init(sizeOfIOThreadPoolForZMQ);
if(NULL == zmqContext) {
const std::string message = utils::errnoToString(errno);
throw exception::Exception(std::string(__FUNCTION__) + ": Failed to instantiate ZMQ context: " + message);
}
return zmqContext;
}
} // namespace mediachanger
} // namespace cta
......@@ -94,6 +94,15 @@ public:
*/
void *release() ;
/**
* Instantiates a ZMQ context.
*
* @param sizeOfIOThreadPoolForZMQ The size of the thread pool used to perform
* IO. This is usually 1 thread.
* @return A pointer to the newly created ZMQ context.
*/
static void *instantiateZmqContext(const int sizeOfIOThreadPoolForZMQ);
private:
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment