remove threadpool.hpp

make link layer not use null lock and null mutex
pull/681/head
Jeff Becker 5 years ago
parent 0b4cb50ac1
commit ec1910b8ca
No known key found for this signature in database
GPG Key ID: F357B3B42F6F9B05

@ -230,8 +230,8 @@ namespace llarp
const SecretKey& m_RouterEncSecret;
protected:
using Lock = util::NullLock;
using Mutex = util::NullMutex;
using Lock = util::Lock;
using Mutex = util::Mutex;
bool
PutSession(const std::shared_ptr< ILinkSession >& s);
@ -249,9 +249,9 @@ namespace llarp
std::unordered_multimap< llarp::Addr, std::shared_ptr< ILinkSession >,
llarp::Addr::Hash >;
Mutex m_AuthedLinksMutex ACQUIRED_BEFORE(m_PendingMutex);
mutable Mutex m_AuthedLinksMutex ACQUIRED_BEFORE(m_PendingMutex);
AuthedLinks m_AuthedLinks GUARDED_BY(m_AuthedLinksMutex);
Mutex m_PendingMutex ACQUIRED_AFTER(m_AuthedLinksMutex);
mutable Mutex m_PendingMutex ACQUIRED_AFTER(m_AuthedLinksMutex);
Pending m_Pending GUARDED_BY(m_PendingMutex);
};

@ -24,7 +24,7 @@
#include <util/mem.hpp>
#include <util/status.hpp>
#include <util/str.hpp>
#include <util/threadpool.hpp>
#include <util/threadpool.h>
#include <functional>
#include <list>

@ -1,6 +1,7 @@
#include <util/logger.hpp>
#include <util/threadpool.hpp>
#include <util/time.hpp>
#include <util/threadpool.h>
#include <util/thread_pool.hpp>
#include <cstring>
#include <functional>

@ -1,10 +1,8 @@
#ifndef LLARP_THREADPOOL_H
#define LLARP_THREADPOOL_H
#include <util/threading.hpp>
#include <util/threadpool.hpp>
#include <util/queue.hpp>
#include <util/thread_pool.hpp>
#include <absl/base/thread_annotations.h>
#include <memory>
#include <queue>

@ -1,101 +0,0 @@
#ifndef LLARP_THREADPOOL_HPP
#define LLARP_THREADPOOL_HPP
#include <util/thread_pool.hpp>
#include <util/threading.hpp>
#include <util/threadpool.h>
namespace llarp
{
namespace thread
{
using Pool = ThreadPool;
struct IsolatedPool : public Pool
{
IsolatedPool(size_t workers, int flags)
: Pool(workers, workers * 128), m_flags(flags)
{
}
void
Join();
/// isolate current thread
/// return true for success
/// return false for failure
/// set errno on fail
/// override me in subclass
virtual bool
IsolateCurrentProcess()
{
return true;
}
// override me to do specific setups after isolation
// return true for success
virtual bool
Isolated()
{
return true;
}
/// called when isolation failed
virtual void
Fail()
{
}
std::thread* m_isolated = nullptr;
int m_flags;
int m_IsolatedWorkers = 0;
const char* IsolatedName = nullptr;
virtual void
MainLoop()
{
}
};
struct _NetIsolatedPool : public IsolatedPool
{
_NetIsolatedPool(std::function< bool(void*, bool) > setupNet,
std::function< void(void*) > runMain, void* user);
/// implement me per platform
virtual bool
IsolateNetwork() = 0;
bool
IsolateCurrentProcess()
{
return IsolateNetwork();
}
bool
Isolated()
{
return m_NetSetup(m_user, true);
}
void
Fail()
{
m_NetSetup(m_user, false);
}
void
MainLoop()
{
m_RunMain(m_user);
}
std::function< bool(void*, bool) > m_NetSetup;
std::function< void(void*) > m_RunMain;
void* m_user;
};
} // namespace thread
} // namespace llarp
#endif
Loading…
Cancel
Save