add NetDb::WaitForReady

This commit is contained in:
Jeff Becker 2016-08-29 15:26:19 -04:00
parent fec49e5609
commit 10ffdb2766
No known key found for this signature in database
GPG key ID: AB950234D6EA286B
2 changed files with 17 additions and 5 deletions

View file

@ -8,6 +8,7 @@
#include <string>
#include <thread>
#include <mutex>
#include <future>
#include "Base.h"
#include "Gzip.h"
@ -48,7 +49,9 @@ namespace data
void Start ();
void Stop ();
/** block until netdb is ready, call only once*/
void WaitForReady();
bool AddRouterInfo (const uint8_t * buf, int len);
bool AddRouterInfo (const IdentHash& ident, const uint8_t * buf, int len);
bool AddLeaseSet (const IdentHash& ident, const uint8_t * buf, int len, std::shared_ptr<i2p::tunnel::InboundTunnel> from);
@ -109,7 +112,8 @@ namespace data
std::shared_ptr<const RouterInfo> GetRandomRouter (Filter filter) const;
private:
std::promise<void> * m_Ready;
mutable std::mutex m_LeaseSetsMutex;
std::map<IdentHash, std::shared_ptr<LeaseSet> > m_LeaseSets;
mutable std::mutex m_RouterInfosMutex;