Fix build errors on old compilers Avoid c++11 constructs. Fix warning due to internal linkage usage in non-internal class.
This commit is contained in:
@@ -29,11 +29,13 @@
|
||||
namespace
|
||||
{
|
||||
class InternalClientContextImpl;
|
||||
class BeaconCleanupHandler;
|
||||
}
|
||||
|
||||
namespace epics {
|
||||
namespace pvAccess {
|
||||
namespace detail {
|
||||
class BeaconCleanupHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* BeaconHandler
|
||||
@@ -94,7 +96,7 @@ private:
|
||||
/**
|
||||
* Callback for cleaning up the beacon
|
||||
*/
|
||||
std::shared_ptr<BeaconCleanupHandler> _callback;
|
||||
std::tr1::shared_ptr<detail::BeaconCleanupHandler> _callback;
|
||||
|
||||
/**
|
||||
* Update beacon.
|
||||
|
||||
@@ -60,9 +60,51 @@ Status ClientChannelImpl::channelDestroyed(
|
||||
Status ClientChannelImpl::channelDisconnected(
|
||||
Status::STATUSTYPE_WARNING, "channel disconnected");
|
||||
|
||||
namespace detail {
|
||||
/**
|
||||
* Handles cleanup of old beacons.
|
||||
*/
|
||||
class BeaconCleanupHandler
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(BeaconCleanupHandler);
|
||||
|
||||
class Callback : public TimerCallback
|
||||
{
|
||||
public:
|
||||
Callback(BeaconCleanupHandler& handler) : m_handler(handler)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void callback() OVERRIDE FINAL;
|
||||
virtual void timerStopped() OVERRIDE FINAL;
|
||||
|
||||
BeaconCleanupHandler& m_handler;
|
||||
};
|
||||
|
||||
BeaconCleanupHandler(InternalClientContextImpl& impl, osiSockAddr addr);
|
||||
~BeaconCleanupHandler();
|
||||
|
||||
/**
|
||||
* Extend the lifetime of the beacon, resetting removal countdown to 0
|
||||
*/
|
||||
void touch() { epicsAtomicSetIntT(&m_count, 0); }
|
||||
|
||||
private:
|
||||
void remove();
|
||||
|
||||
std::tr1::shared_ptr<BeaconCleanupHandler::Callback> m_callback;
|
||||
osiSockAddr m_from;
|
||||
InternalClientContextImpl& m_impl;
|
||||
int m_count;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
}}
|
||||
|
||||
namespace {
|
||||
using namespace epics::pvAccess;
|
||||
using namespace epics::pvAccess::detail;
|
||||
|
||||
class ChannelGetFieldRequestImpl;
|
||||
|
||||
@@ -3040,45 +3082,6 @@ enum ContextState {
|
||||
CONTEXT_DESTROYED
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Handles cleanup of old beacons.
|
||||
*/
|
||||
class BeaconCleanupHandler
|
||||
{
|
||||
public:
|
||||
POINTER_DEFINITIONS(BeaconCleanupHandler);
|
||||
|
||||
class Callback : public TimerCallback
|
||||
{
|
||||
public:
|
||||
Callback(BeaconCleanupHandler& handler) : m_handler(handler)
|
||||
{
|
||||
}
|
||||
|
||||
virtual void callback() OVERRIDE FINAL;
|
||||
virtual void timerStopped() OVERRIDE FINAL;
|
||||
|
||||
BeaconCleanupHandler& m_handler;
|
||||
};
|
||||
|
||||
BeaconCleanupHandler(InternalClientContextImpl& impl, osiSockAddr addr);
|
||||
~BeaconCleanupHandler();
|
||||
|
||||
/**
|
||||
* Extend the lifetime of the beacon, resetting removal countdown to 0
|
||||
*/
|
||||
void touch() { epicsAtomicSetIntT(&m_count, 0); }
|
||||
|
||||
private:
|
||||
void remove();
|
||||
|
||||
std::shared_ptr<BeaconCleanupHandler::Callback> m_callback;
|
||||
osiSockAddr m_from;
|
||||
InternalClientContextImpl& m_impl;
|
||||
int m_count;
|
||||
};
|
||||
|
||||
class InternalClientContextImpl :
|
||||
public ClientContextImpl,
|
||||
public ChannelProvider
|
||||
@@ -4397,7 +4400,7 @@ private:
|
||||
char ipa[64];
|
||||
sockAddrToDottedIP(&responseFrom->sa, ipa, sizeof(ipa));
|
||||
LOG(logLevelDebug, "Tracked beacon limit reached (%d), ignoring %s\n", maxTrackedBeacons, ipa);
|
||||
return nullptr;
|
||||
return BeaconHandler::shared_pointer();
|
||||
}
|
||||
|
||||
// stores weak_ptr
|
||||
@@ -4610,43 +4613,9 @@ private:
|
||||
|
||||
TransportRegistry::transportVector_t m_flushTransports;
|
||||
|
||||
friend class BeaconCleanupHandler;
|
||||
friend class epics::pvAccess::detail::BeaconCleanupHandler;
|
||||
};
|
||||
|
||||
|
||||
BeaconCleanupHandler::BeaconCleanupHandler(InternalClientContextImpl& impl, osiSockAddr addr) :
|
||||
m_from(addr),
|
||||
m_impl(impl),
|
||||
m_count(0)
|
||||
{
|
||||
m_callback.reset(new Callback(*this));
|
||||
m_impl.m_timer->schedulePeriodic(m_callback, maxBeaconLifetime / 4, maxBeaconLifetime / 4);
|
||||
}
|
||||
|
||||
BeaconCleanupHandler::~BeaconCleanupHandler()
|
||||
{
|
||||
m_impl.m_timer->cancel(m_callback);
|
||||
}
|
||||
|
||||
void BeaconCleanupHandler::Callback::callback()
|
||||
{
|
||||
if (epicsAtomicIncrIntT(&m_handler.m_count) >= 5) {
|
||||
m_handler.remove();
|
||||
}
|
||||
}
|
||||
|
||||
void BeaconCleanupHandler::Callback::timerStopped()
|
||||
{
|
||||
m_handler.remove();
|
||||
}
|
||||
|
||||
void BeaconCleanupHandler::remove()
|
||||
{
|
||||
Lock guard(m_impl.m_beaconMapMutex);
|
||||
m_impl.m_timer->cancel(m_callback);
|
||||
m_impl.m_beaconHandlers.erase(m_from);
|
||||
}
|
||||
|
||||
size_t InternalClientContextImpl::num_instances;
|
||||
size_t InternalClientContextImpl::InternalChannelImpl::num_instances;
|
||||
size_t InternalClientContextImpl::InternalChannelImpl::num_active;
|
||||
@@ -4850,5 +4819,42 @@ ChannelProvider::shared_pointer createClientProvider(const Configuration::shared
|
||||
return external;
|
||||
}
|
||||
|
||||
namespace detail {
|
||||
|
||||
BeaconCleanupHandler::BeaconCleanupHandler(InternalClientContextImpl& impl, osiSockAddr addr) :
|
||||
m_from(addr),
|
||||
m_impl(impl),
|
||||
m_count(0)
|
||||
{
|
||||
m_callback.reset(new Callback(*this));
|
||||
m_impl.m_timer->schedulePeriodic(m_callback, maxBeaconLifetime / 4, maxBeaconLifetime / 4);
|
||||
}
|
||||
|
||||
BeaconCleanupHandler::~BeaconCleanupHandler()
|
||||
{
|
||||
m_impl.m_timer->cancel(m_callback);
|
||||
}
|
||||
|
||||
void BeaconCleanupHandler::Callback::callback()
|
||||
{
|
||||
if (epicsAtomicIncrIntT(&m_handler.m_count) >= 5) {
|
||||
m_handler.remove();
|
||||
}
|
||||
}
|
||||
|
||||
void BeaconCleanupHandler::Callback::timerStopped()
|
||||
{
|
||||
m_handler.remove();
|
||||
}
|
||||
|
||||
void BeaconCleanupHandler::remove()
|
||||
{
|
||||
Lock guard(m_impl.m_beaconMapMutex);
|
||||
m_impl.m_timer->cancel(m_callback);
|
||||
m_impl.m_beaconHandlers.erase(m_from);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user