aboutsummaryrefslogtreecommitdiffstats
path: root/fnet
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2016-12-14 22:58:54 +0100
committerHenning Baldersheim <balder@yahoo-inc.com>2016-12-15 13:12:36 +0100
commit2a85dc3fd5af5c33601cf04ead06c7545fa46d75 (patch)
treef46f355235fd7684a9f8a6bb562797fd985d1180 /fnet
parentd9b45214d28207564329991afe70afc358fe6d12 (diff)
Split in hash_xxx, array, lru, cache ++ in hpp files. To reduce clinon build
Diffstat (limited to 'fnet')
-rw-r--r--fnet/src/vespa/fnet/channel.h8
-rw-r--r--fnet/src/vespa/fnet/channellookup.cpp36
-rw-r--r--fnet/src/vespa/fnet/channellookup.h20
-rw-r--r--fnet/src/vespa/fnet/context.h5
-rw-r--r--fnet/src/vespa/fnet/controlpacket.h2
-rw-r--r--fnet/src/vespa/fnet/fnet.h2
-rw-r--r--fnet/src/vespa/fnet/ipackethandler.h4
-rw-r--r--fnet/src/vespa/fnet/packet.h2
8 files changed, 56 insertions, 23 deletions
diff --git a/fnet/src/vespa/fnet/channel.h b/fnet/src/vespa/fnet/channel.h
index ee8ad42ff90..d2c798d0b5e 100644
--- a/fnet/src/vespa/fnet/channel.h
+++ b/fnet/src/vespa/fnet/channel.h
@@ -2,6 +2,14 @@
#pragma once
+#include "context.h"
+#include "ipackethandler.h"
+#include <memory>
+
+#define FNET_NOID ((uint32_t)-1)
+
+class FNET_Connection;
+class FNET_IPacketHandler;
/**
* A channel object represents an endpoint in a point-to-point packet
* based virtual connection. Clients open channels by invoking the
diff --git a/fnet/src/vespa/fnet/channellookup.cpp b/fnet/src/vespa/fnet/channellookup.cpp
index df05b691bc1..1ba63a6019b 100644
--- a/fnet/src/vespa/fnet/channellookup.cpp
+++ b/fnet/src/vespa/fnet/channellookup.cpp
@@ -1,11 +1,23 @@
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-#include <vespa/fastos/fastos.h>
-#include <vespa/fnet/fnet.h>
+#include "channellookup.h"
+#include "vespa/fnet/channel.h"
+#include "controlpacket.h"
+#include "ipackethandler.h"
+#include <vespa/vespalib/stllike/hash_map.hpp>
+namespace fnet {
+
+struct ChannelMap : public vespalib::hash_map<uint32_t, FNET_Channel *> {
+ using Parent = vespalib::hash_map<uint32_t, FNET_Channel *>;
+ ChannelMap(size_t sz) : Parent(sz) { }
+};
+
+}
+using fnet::ChannelMap;
FNET_ChannelLookup::FNET_ChannelLookup(uint32_t hashSize)
- : _map(hashSize)
+ : _map(std::make_unique<ChannelMap>(hashSize))
{
assert(hashSize > 0);
}
@@ -13,7 +25,7 @@ FNET_ChannelLookup::FNET_ChannelLookup(uint32_t hashSize)
FNET_ChannelLookup::~FNET_ChannelLookup()
{
- assert(_map.empty());
+ assert(_map->empty());
}
@@ -21,15 +33,15 @@ void
FNET_ChannelLookup::Register(FNET_Channel *channel)
{
assert(channel->GetHandler() != nullptr);
- _map[channel->GetID()] = channel;
+ (*_map)[channel->GetID()] = channel;
}
FNET_Channel*
FNET_ChannelLookup::Lookup(uint32_t id)
{
- auto found = _map.find(id);
- return ((found != _map.end()) ? found->second : nullptr);
+ auto found = _map->find(id);
+ return ((found != _map->end()) ? found->second : nullptr);
}
@@ -38,7 +50,7 @@ FNET_ChannelLookup::Broadcast(FNET_ControlPacket *cpacket)
{
std::vector<uint32_t> toRemove;
std::vector<FNET_Channel::UP> toFree;
- for (const auto & pair : _map) {
+ for (const auto & pair : *_map) {
FNET_Channel *ch = pair.second;
FNET_IPacketHandler::HP_RetCode hp_rc = ch->Receive(cpacket);
if (hp_rc > FNET_IPacketHandler::FNET_KEEP_CHANNEL) {
@@ -49,7 +61,7 @@ FNET_ChannelLookup::Broadcast(FNET_ControlPacket *cpacket)
}
}
for (uint32_t id : toRemove) {
- _map.erase(id);
+ _map->erase(id);
}
return toFree;
}
@@ -57,10 +69,10 @@ FNET_ChannelLookup::Broadcast(FNET_ControlPacket *cpacket)
bool
FNET_ChannelLookup::Unregister(FNET_Channel *channel)
{
- auto found = _map.find(channel->GetID());
- if (found == _map.end()) {
+ auto found = _map->find(channel->GetID());
+ if (found == _map->end()) {
return false;
}
- _map.erase(found);
+ _map->erase(found);
return true;
}
diff --git a/fnet/src/vespa/fnet/channellookup.h b/fnet/src/vespa/fnet/channellookup.h
index df694c0fa61..7700a4f927a 100644
--- a/fnet/src/vespa/fnet/channellookup.h
+++ b/fnet/src/vespa/fnet/channellookup.h
@@ -2,7 +2,15 @@
#pragma once
-#include <vespa/vespalib/stllike/hash_map.h>
+#include <memory>
+#include <vector>
+
+namespace fnet {
+ class ChannelMap;
+}
+
+class FNET_Channel;
+class FNET_ControlPacket;
/**
* This class handles registration/deregistration and lookup of
@@ -14,8 +22,7 @@
class FNET_ChannelLookup
{
private:
- typedef vespalib::hash_map<uint32_t, FNET_Channel *> ChannelMap;
- ChannelMap _map;
+ std::unique_ptr<fnet::ChannelMap> _map;
FNET_ChannelLookup(const FNET_ChannelLookup &);
FNET_ChannelLookup &operator=(const FNET_ChannelLookup &);
@@ -37,11 +44,6 @@ public:
~FNET_ChannelLookup();
/**
- * @return number of registered channels.
- **/
- uint32_t GetEntryCnt() { return _map.size(); }
-
- /**
* Register a channel. If you register several channels with the
* same ID, only the last registered channel will be availible by
* calling the Lookup method.
@@ -75,7 +77,7 @@ public:
* @return vector of all channels to be freed.
* @param cpacket the control packet you want to broadcast.
**/
- std::vector<FNET_Channel::UP> Broadcast(FNET_ControlPacket *cpacket);
+ std::vector<std::unique_ptr<FNET_Channel>> Broadcast(FNET_ControlPacket *cpacket);
/**
* Unregister a channel. This method uses both the channel ID and
diff --git a/fnet/src/vespa/fnet/context.h b/fnet/src/vespa/fnet/context.h
index 27e9533436f..782009e5bec 100644
--- a/fnet/src/vespa/fnet/context.h
+++ b/fnet/src/vespa/fnet/context.h
@@ -2,6 +2,11 @@
#pragma once
+class FNET_IOComponent;
+class FNET_Connector;
+class FNET_Connection;
+class FNET_Channel;
+class FNET_IExecutable;
/**
* This class indicates the context of a packet. It is external to the
* packet class because a single packet may occur in many contexts at
diff --git a/fnet/src/vespa/fnet/controlpacket.h b/fnet/src/vespa/fnet/controlpacket.h
index 35b6b8470c6..2ecbef8fcbf 100644
--- a/fnet/src/vespa/fnet/controlpacket.h
+++ b/fnet/src/vespa/fnet/controlpacket.h
@@ -2,6 +2,8 @@
#pragma once
+#include "packet.h"
+
/**
* Packets of this type may be used to send simple control signals
* between components in the application. Control packets only contain
diff --git a/fnet/src/vespa/fnet/fnet.h b/fnet/src/vespa/fnet/fnet.h
index 85f4f3e750e..6144817b885 100644
--- a/fnet/src/vespa/fnet/fnet.h
+++ b/fnet/src/vespa/fnet/fnet.h
@@ -11,8 +11,6 @@
// DEFINES
-#define FNET_NOID ((uint32_t)-1)
-
// THREAD/MUTEX STUFF
#ifdef FASTOS_NO_THREADS
diff --git a/fnet/src/vespa/fnet/ipackethandler.h b/fnet/src/vespa/fnet/ipackethandler.h
index b0af1ba0484..7042b092b51 100644
--- a/fnet/src/vespa/fnet/ipackethandler.h
+++ b/fnet/src/vespa/fnet/ipackethandler.h
@@ -2,6 +2,10 @@
#pragma once
+#include "context.h"
+
+class FNET_Packet;
+
/**
* Interface implemented by objects that can handle packets.
**/
diff --git a/fnet/src/vespa/fnet/packet.h b/fnet/src/vespa/fnet/packet.h
index a7033b8008f..0dea973ab9a 100644
--- a/fnet/src/vespa/fnet/packet.h
+++ b/fnet/src/vespa/fnet/packet.h
@@ -4,6 +4,8 @@
#include <vespa/vespalib/stllike/string.h>
+class FNET_DataBuffer;
+
/**
* This is a general superclass of all packets. Packets are used to
* encapsulate data when communicating with other computers through