Cuberite
A lightweight, fast and extensible game server for Minecraft
NetworkLookup.h
Go to the documentation of this file.
1 
2 // NetworkLookup.h
3 
4 // Declares the cNetworkLookup class representing an executor for asynchronous lookup tasks
5 
6 #pragma once
7 
8 #include <functional>
9 
10 #include "IsThread.h"
11 #include "Queue.h"
12 
13 
14 
15 
16 
18  public cIsThread
19 {
20 public:
21 
23  virtual ~cNetworkLookup() override;
24 
26  void ScheduleLookup(std::function<void()> a_Lookup);
27 
29  void Stop();
30 
31 protected:
32 
34  virtual void Execute() override final;
35 
36 private:
37 
39  cQueue<std::function<void()>> m_WorkQueue;
40 };
41 
42 
virtual ~cNetworkLookup() override
virtual void Execute() override final
Process the queue until the thread is stopped.
void ScheduleLookup(std::function< void()> a_Lookup)
Schedule a lookup task for execution.
void Stop()
Cancels any scheduled lookups and joins the lookup thread.
cQueue< std::function< void()> > m_WorkQueue
The queue of lookup tasks waiting to be executed.
Definition: NetworkLookup.h:39
Definition: Queue.h:44