Vowpal Wabbit
spanning_tree.h
Go to the documentation of this file.
1 #pragma once
2 
3 #ifdef _WIN32
4 #define NOMINMAX
5 #include <WinSock2.h>
6 #include <Windows.h>
7 #include <WS2tcpip.h>
8 #include <io.h>
9 
10 #define CLOSESOCK closesocket
11 #define inet_ntop InetNtopA
12 
13 typedef unsigned int uint32_t;
14 typedef unsigned short uint16_t;
15 typedef int socklen_t;
16 typedef SOCKET socket_t;
17 
18 namespace std
19 {
20 // forward declare promise as C++/CLI doesn't allow usage in header files
21 template <typename T>
22 class future;
23 } // namespace std
24 #else
25 #include <unistd.h>
26 #include <sys/socket.h>
27 #include <netinet/in.h>
28 #include <netinet/tcp.h>
29 #include <netdb.h>
30 #include <strings.h>
31 #include <arpa/inet.h>
32 
33 #define CLOSESOCK close
34 
35 typedef int socket_t;
36 
37 #include <future>
38 #endif
39 
40 namespace VW
41 {
43 {
44  private:
45  bool m_stop;
47  uint16_t m_port;
48 
49  // future to signal end of thread running.
50  // Need a pointer since C++/CLI doesn't like futures yet
51  std::future<void>* m_future;
52 
53  bool m_quiet;
54 
55  public:
56  SpanningTree(short unsigned int port = 26543, bool quiet = false);
57  ~SpanningTree();
58 
59  short unsigned int BoundPort();
60 
61  void Start();
62  void Run();
63  void Stop();
64 };
65 } // namespace VW
int socket_t
Definition: spanning_tree.h:35
std::future< void > * m_future
Definition: spanning_tree.h:51
Definition: autolink.cc:11
int socket_t
Definition: allreduce.h:42