tracy/profiler/src/ResolvService.hpp
2019-09-21 15:43:01 +02:00

39 lines
705 B
C++

#ifndef __RESOLVSERVICE_HPP__
#define __RESOLVSERVICE_HPP__
#include <atomic>
#include <condition_variable>
#include <functional>
#include <mutex>
#include <stdint.h>
#include <string>
#include <thread>
#include <vector>
class ResolvService
{
struct QueueItem
{
uint32_t ip;
std::function<void(std::string&&)> callback;
};
public:
ResolvService( int port );
~ResolvService();
void Query( uint32_t ip, const std::function<void(std::string&&)>& callback );
private:
void Worker();
std::atomic<bool> m_exit;
std::mutex m_lock;
std::condition_variable m_cv;
std::vector<QueueItem> m_queue;
int m_port;
std::thread m_thread;
};
#endif