add threadpool for ntcp dh

This commit is contained in:
Jeff Becker 2018-02-20 11:38:48 -05:00
parent b02464990b
commit 91fdb038d9
No known key found for this signature in database
GPG key ID: F357B3B42F6F9B05
3 changed files with 98 additions and 17 deletions

View file

@ -12,6 +12,7 @@
#include "RouterInfo.h"
#include "I2NPProtocol.h"
#include "TransportSession.h"
#include "CryptoWorker.h"
namespace i2p
{
@ -131,6 +132,8 @@ namespace transport
{
public:
typedef i2p::worker::ThreadPool<NTCPSession> Pool;
enum RemoteAddressType
{
eIP4Address,
@ -146,7 +149,7 @@ namespace transport
};
NTCPServer ();
NTCPServer (int workers=4);
~NTCPServer ();
void Start ();
@ -193,6 +196,11 @@ namespace transport
void ScheduleTermination ();
void HandleTerminationTimer (const boost::system::error_code& ecode);
void Work(std::shared_ptr<NTCPSession> conn, Pool::WorkFunc work)
{
m_CryptoPool->Offer({conn, work});
}
private:
bool m_IsRunning;
@ -210,6 +218,8 @@ namespace transport
boost::asio::ip::tcp::resolver m_Resolver;
boost::asio::ip::tcp::endpoint * m_ProxyEndpoint;
std::shared_ptr<Pool> m_CryptoPool;
uint16_t m_SoftLimit, m_HardLimit;
public: