eliminate overhead

This commit is contained in:
orignal 2016-11-01 17:49:42 -04:00
parent 44af5e04e4
commit 1ecd5250fc

View File

@ -10,7 +10,9 @@
#include "Tunnel.h" #include "Tunnel.h"
#include "TunnelPool.h" #include "TunnelPool.h"
#include "Destination.h" #include "Destination.h"
#ifdef WITH_EVENTS
#include "Event.h" #include "Event.h"
#endif
namespace i2p namespace i2p
{ {
@ -71,7 +73,9 @@ namespace tunnel
{ {
if (!m_IsActive) return; if (!m_IsActive) return;
{ {
#ifdef WITH_EVENTS
EmitTunnelEvent("tunnels.created", createdTunnel); EmitTunnelEvent("tunnels.created", createdTunnel);
#endif
std::unique_lock<std::mutex> l(m_InboundTunnelsMutex); std::unique_lock<std::mutex> l(m_InboundTunnelsMutex);
m_InboundTunnels.insert (createdTunnel); m_InboundTunnels.insert (createdTunnel);
} }
@ -83,7 +87,9 @@ namespace tunnel
{ {
if (expiredTunnel) if (expiredTunnel)
{ {
#ifdef WITH_EVENTS
EmitTunnelEvent("tunnels.expired", expiredTunnel); EmitTunnelEvent("tunnels.expired", expiredTunnel);
#endif
expiredTunnel->SetTunnelPool (nullptr); expiredTunnel->SetTunnelPool (nullptr);
for (auto& it: m_Tests) for (auto& it: m_Tests)
if (it.second.second == expiredTunnel) it.second.second = nullptr; if (it.second.second == expiredTunnel) it.second.second = nullptr;
@ -97,7 +103,9 @@ namespace tunnel
{ {
if (!m_IsActive) return; if (!m_IsActive) return;
{ {
#ifdef WITH_EVENTS
EmitTunnelEvent("tunnels.created", createdTunnel); EmitTunnelEvent("tunnels.created", createdTunnel);
#endif
std::unique_lock<std::mutex> l(m_OutboundTunnelsMutex); std::unique_lock<std::mutex> l(m_OutboundTunnelsMutex);
m_OutboundTunnels.insert (createdTunnel); m_OutboundTunnels.insert (createdTunnel);
} }
@ -108,7 +116,9 @@ namespace tunnel
{ {
if (expiredTunnel) if (expiredTunnel)
{ {
#ifdef WITH_EVENTS
EmitTunnelEvent("tunnels.expired", expiredTunnel); EmitTunnelEvent("tunnels.expired", expiredTunnel);
#endif
expiredTunnel->SetTunnelPool (nullptr); expiredTunnel->SetTunnelPool (nullptr);
for (auto& it: m_Tests) for (auto& it: m_Tests)
if (it.second.first == expiredTunnel) it.second.first = nullptr; if (it.second.first == expiredTunnel) it.second.first = nullptr;