Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
cta
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
dCache
cta
Commits
848a9f6e
Commit
848a9f6e
authored
8 years ago
by
Steven Murray
Browse files
Options
Downloads
Patches
Plain Diff
Removed unused SmartZmqContext
parent
158f0e35
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
mediachanger/CMakeLists.txt
+0
-1
0 additions, 1 deletion
mediachanger/CMakeLists.txt
mediachanger/SmartZmqContext.cpp
+0
-122
0 additions, 122 deletions
mediachanger/SmartZmqContext.cpp
mediachanger/SmartZmqContext.hpp
+0
-126
0 additions, 126 deletions
mediachanger/SmartZmqContext.hpp
with
0 additions
and
249 deletions
mediachanger/CMakeLists.txt
+
0
−
1
View file @
848a9f6e
...
...
@@ -49,7 +49,6 @@ set (MEDIACHANGER_LIB_SRC_FILES
RmcProxyTcpIp.cpp
RmcUnmountMsgBody.cpp
ScsiLibrarySlot.cpp
SmartZmqContext.cpp
TapeLibraryType.cpp
ZmqContextSingleton.cpp
ZmqMsg.cpp
...
...
This diff is collapsed.
Click to expand it.
mediachanger/SmartZmqContext.cpp
deleted
100644 → 0
+
0
−
122
View file @
158f0e35
/*
* The CERN Tape Archive(CTA) project
* Copyright(C) 2015 CERN
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
*(at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include
"mediachanger/SmartZmqContext.hpp"
#include
"common/utils/utils.hpp"
#include
<errno.h>
#include
<unistd.h>
#include
<zmq.h>
namespace
cta
{
namespace
mediachanger
{
//-----------------------------------------------------------------------------
// constructor
//-----------------------------------------------------------------------------
SmartZmqContext
::
SmartZmqContext
()
throw
()
:
m_zmqContext
(
NULL
)
{
}
//-----------------------------------------------------------------------------
// constructor
//-----------------------------------------------------------------------------
SmartZmqContext
::
SmartZmqContext
(
void
*
const
zmqContext
)
throw
()
:
m_zmqContext
(
zmqContext
)
{
}
//-----------------------------------------------------------------------------
// reset
//-----------------------------------------------------------------------------
void
SmartZmqContext
::
reset
(
void
*
const
zmqContext
)
throw
()
{
// If the new ZMQ context is not the one already owned
if
(
zmqContext
!=
m_zmqContext
)
{
// If this smart pointer still owns a ZMQ context, then terminate it
if
(
m_zmqContext
!=
NULL
)
{
zmq_term
(
m_zmqContext
);
}
// Take ownership of the new ZMQ context
m_zmqContext
=
zmqContext
;
}
}
//-----------------------------------------------------------------------------
// SmartZmqContext assignment operator
//-----------------------------------------------------------------------------
SmartZmqContext
&
SmartZmqContext
::
operator
=
(
SmartZmqContext
&
obj
)
{
reset
(
obj
.
release
());
return
*
this
;
}
//-----------------------------------------------------------------------------
// destructor
//-----------------------------------------------------------------------------
SmartZmqContext
::~
SmartZmqContext
()
throw
()
{
// ZMQ sends an abort on exit when cleaned up this way under some
// circumstances, so we purposely do not clean up the context (zmq_term) and
// leave a resource leak, which in our use case is one-off situation
// per process, and it gets cleaned up on process termination, which happens
// very soon after this destructor being called.
//reset();
}
//-----------------------------------------------------------------------------
// get
//-----------------------------------------------------------------------------
void
*
SmartZmqContext
::
get
()
const
throw
()
{
return
m_zmqContext
;
}
//-----------------------------------------------------------------------------
// release
//-----------------------------------------------------------------------------
void
*
SmartZmqContext
::
release
()
{
// If this smart pointer does not own a ZMQ context
if
(
NULL
==
m_zmqContext
)
{
cta
::
exception
::
NotAnOwner
ex
;
ex
.
getMessage
()
<<
"Smart pointer does not own a ZMQ context"
;
throw
ex
;
}
void
*
const
tmp
=
m_zmqContext
;
// A NULL value indicates this smart pointer does not own a ZMQ context
m_zmqContext
=
NULL
;
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
This diff is collapsed.
Click to expand it.
mediachanger/SmartZmqContext.hpp
deleted
100644 → 0
+
0
−
126
View file @
158f0e35
/*
* The CERN Tape Archive(CTA) project
* Copyright(C) 2015 CERN
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
*(at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include
"common/exception/NotAnOwner.hpp"
#include
<stdio.h>
namespace
cta
{
namespace
mediachanger
{
/**
* A smart pointer that owns a ZMQ context. If the smart pointer goes out of
* scope and it owns a ZMQ context, then it will terminate that context by
* calling zmq_term().
*/
class
SmartZmqContext
{
public:
/**
* Constructor.
*/
SmartZmqContext
()
throw
();
/**
* Constructor.
*
* @param zmqContext The ZMQ context to be owned by the smart pointer.
*/
SmartZmqContext
(
void
*
const
zmqContext
)
throw
();
/**
* Take ownership of the specified ZMQ context, terminating the previously
* owned ZMQ context if there is one and it is not the same as the one
* specified.
*
* @param zmqContext The ZMQ context to be owned, defaults to NULL if not
* specified, where NULL means this smart pointer will not own a ZMQ context
* after the reset() method returns.
*/
void
reset
(
void
*
const
zmqContext
=
NULL
)
throw
();
/**
* SmartZmqContext assignment operator.
*
* This function does the following:
* <ul>
* <li> Calls release on the previous owner (obj);
* <li> Terminates the ZMQ context of this object if it already owns one.
* <li> Makes this object the owner of the ZMQ context released from the
* previous owner (obj).
* </ul>
*/
SmartZmqContext
&
operator
=
(
SmartZmqContext
&
obj
);
/**
* Destructor.
*
* If the smart pointer owns a ZMQ context, then the destructor will
* terminate it by calling zmq_term().
*/
~
SmartZmqContext
()
throw
();
/**
* Returns the owned ZMQ context or NULL if this smart pointer does not own
* one.
*
* @return The owned ZMQ context or NULL.
*/
void
*
get
()
const
throw
();
/**
* Releases the owned ZMQ context.
*
* @return The released ZMQ context.
*/
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:
/**
* The owned ZMQ context. A value of NULL means this smart pointer does not
* own a ZMQ context.
*/
void
*
m_zmqContext
;
/**
* Private copy-constructor to prevent users from trying to create a new
* copy of an object of this class.
*
* Not implemented so that it cannot be called.
*/
SmartZmqContext
(
const
SmartZmqContext
&
obj
)
throw
();
};
// class SmartZmqContext
}
// namespace mediachanger
}
// namespace cta
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment