huzzah it builds, time to test soon!

pull/1184/head
Thomas Winget 4 years ago
parent da79b14703
commit f712acc486

@ -197,7 +197,8 @@ set(LIB_SRC
service/sendcontext.cpp
service/session.cpp
service/tag_lookup_job.cpp
service/tag.cpp)
service/tag.cpp
tooling/router_event.cpp)
if(TRACY_ROOT)
set(LIB_SRC ${LIB_SRC} ${TRACY_ROOT}/TracyClient.cpp)
@ -207,12 +208,12 @@ if(TESTNET)
set(LIB_SRC ${LIB_SRC} testnet.c)
endif()
add_library(${STATIC_LIB} STATIC ${LIB_SRC})
if(WITH_HIVE)
set(LIB_SRC ${LIB_SRC} tooling/router_hive.cpp tooling/router_event.cpp)
set(LIB_SRC ${LIB_SRC} tooling/router_hive.cpp)
endif()
add_library(${STATIC_LIB} STATIC ${LIB_SRC})
target_include_directories(${STATIC_LIB} PUBLIC ${CURL_INCLUDE_DIRS})
target_link_libraries(${STATIC_LIB} PUBLIC cxxopts ${ABYSS_LIB} ${PLATFORM_LIB} ${UTIL_LIB} ${CRYPTOGRAPHY_LIB})

@ -273,7 +273,7 @@ namespace llarp
GossipRCIfNeeded(const RouterContact rc) = 0;
virtual void
NotifyRouterEvent(const tooling::RouterEvent & event) const = 0;
NotifyRouterEvent(tooling::RouterEventPtr event) const = 0;
};
} // namespace llarp

@ -131,12 +131,12 @@ namespace llarp
}
void
Router::NotifyRouterEvent(const tooling::RouterEvent & event) const
Router::NotifyRouterEvent(tooling::RouterEventPtr event) const
{
#ifdef LOKINET_HIVE
hive->NotifyEvent(event);
hive->NotifyEvent(std::move(event));
#elif LOKINET_DEBUG
LogDebug(event.ToString());
LogDebug(event->ToString());
#endif
}

@ -45,7 +45,7 @@
namespace tooling
{
struct RouterEvent;
struct RouterHive;
} // namespace tooling
namespace llarp
@ -315,7 +315,7 @@ namespace llarp
GossipRCIfNeeded(const RouterContact rc) override;
void
NotifyRouterEvent(const tooling::RouterEvent & event) const override;
NotifyRouterEvent(tooling::RouterEventPtr event) const override;
Router(std::shared_ptr< llarp::thread::ThreadPool > worker,
llarp_ev_loop_ptr __netloop, std::shared_ptr< Logic > logic);

@ -2,14 +2,18 @@
#include <tooling/router_hive.hpp>
#include <llarp/router_id.hpp>
#include <llarp/path/path.hpp>
#include <path/path.hpp>
namespace tooling
{
RouterEvent::RouterEvent(llarp::RouterID routerID)
: routerID(routerID)
{
}
PathBuildAttemptEvent::PathBuildAttemptEvent(const llarp::RouterID& routerID, std::vector<llarp::path::PathHopConfig> hops)
: routerID(routerID), hops(hops)
: RouterEvent(routerID), hops(hops)
{
}

@ -1,13 +1,14 @@
#pragma once
#include <router_id.hpp>
#include <string>
#include <vector>
#include <memory>
namespace llarp
{
struct RouterID;
namespace path
{
struct PathHopConfig;
@ -24,6 +25,8 @@ namespace tooling
struct RouterEvent
{
RouterEvent(llarp::RouterID);
virtual ~RouterEvent() = default;
virtual void Process(RouterHive& hive) const = 0;
@ -33,6 +36,8 @@ namespace tooling
llarp::RouterID routerID;
};
typedef std::unique_ptr<RouterEvent> RouterEventPtr;
struct PathBuildAttemptEvent : public RouterEvent
{

@ -1,13 +1,15 @@
#include <tooling/router_hive.hpp>
#include "include/llarp.h"
#include "include/llarp.hpp"
#include "llarp.h"
#include "llarp.hpp"
#include <chrono>
namespace tooling
{
const size_t RouterHive::MAX_EVENT_QUEUE_SIZE = 200;
RouterHive::RouterHive(size_t eventQueueSize) : eventQueue(eventQueueSize)
{
}
@ -27,7 +29,8 @@ namespace tooling
for (llarp_main* ctx : routers)
{
routerMainThreads.emplace_back({std::bind(&llarp_main_run, ctx, opts)});
std::thread t{std::bind(&llarp_main_run, ctx, opts)};
routerMainThreads.emplace_back(std::move(t));
}
}
@ -51,7 +54,7 @@ namespace tooling
}
void
RouterHive::NotifyEvent(RouterEvent event)
RouterHive::NotifyEvent(RouterEventPtr event)
{
if(eventQueue.tryPushBack(std::move(event))
!= llarp::thread::QueueReturn::Success)
@ -65,14 +68,14 @@ namespace tooling
{
while(not eventQueue.empty())
{
RouterEvent event = eventQueue.popFront();
RouterEventPtr event = eventQueue.popFront();
event.Process(*this);
event->Process(*this);
}
}
void
RouterHive::ProcessPathBuildAttempt(PathBuildAttemptEvent event)
RouterHive::ProcessPathBuildAttempt(const PathBuildAttemptEvent& event)
{
}

@ -16,7 +16,7 @@ namespace tooling
struct RouterHive
{
constexpr size_t MAX_EVENT_QUEUE_SIZE = 200;
static const size_t MAX_EVENT_QUEUE_SIZE;
RouterHive(size_t eventQueueSize = MAX_EVENT_QUEUE_SIZE);
@ -30,7 +30,7 @@ namespace tooling
StopRouters();
void
NotifyEvent(RouterEvent event);
NotifyEvent(RouterEventPtr event);
void
ProcessEventQueue();
@ -41,14 +41,14 @@ namespace tooling
*/
void
ProcessPathBuildAttempt(PathBuildAttemptEvent event);
ProcessPathBuildAttempt(const PathBuildAttemptEvent& event);
std::vector<llarp_main *> routers;
std::vector<std::thread> routerMainThreads;
llarp::thread::Queue<RouterEvent> eventQueue;
llarp::thread::Queue<RouterEventPtr> eventQueue;
};
} // namespace tooling

Loading…
Cancel
Save