Dangerous SNMP
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
iosystem.hpp
1 #pragma once
2 
3 #include <map>
4 #include <memory>
5 #include <mutex>
6 #include <thread>
7 
8 #include "dangerous/snmp/exception.hpp"
9 
10 #include "bytestream.hpp"
11 
12 
13 namespace dangerous { namespace snmp {
14 
15 class IoSystem {
16 public:
17  IoSystem() throw( Exception );
18  ~IoSystem();
19 
20  void registerInput( int handle, std::shared_ptr<ByteStream> buffer );
21  void registerOutput( int handle, std::shared_ptr<ByteStream> buffer );
22 
23  void unregisterInput( int handle );
24  void unregisterOutput( int handle );
25 
26  void main();
27 
31  void start();
32 
36  void stop();
37 
38  void wakeup();
39 
40 protected:
44  bool isStopped;
45 
47  std::thread thisThread;
48 
49  std::mutex lock;
50  std::map< int, std::shared_ptr<ByteStream> > inMap;
51  std::map< int, std::shared_ptr<ByteStream> > outMap;
52 
53  int localSockets[ 2 ];
54 };
55 
56 } }
57 
Definition: iosystem.hpp:15
std::thread thisThread
This is the thread for this instance.
Definition: iosystem.hpp:47
void stop()
This stops the IoSystem thread, if it's running.
bool isStopped
This is whether or not the thread should attempt to stop.
Definition: iosystem.hpp:44
This defines the base exception class for Dangerous SNMP.
Definition: exception.hpp:10
void start()
This starts the the IoSystem as a thread.