1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-25 22:17:45 +00:00
sapphire/src/common/Network/Hive.h

57 lines
1.4 KiB
C
Raw Normal View History

2017-08-08 13:53:47 +02:00
#ifndef HIVE_H_
#define HIVE_H_
#include <boost/asio.hpp>
#include <boost/enable_shared_from_this.hpp>
namespace Core {
namespace Network {
2017-08-08 13:53:47 +02:00
class Hive :
public boost::enable_shared_from_this< Hive >
{
private:
boost::asio::io_service m_io_service;
boost::shared_ptr< boost::asio::io_service::work > m_work_ptr;
volatile uint32_t m_shutdown;
2017-08-08 13:53:47 +02:00
private:
Hive( const Hive& rhs );
2017-08-08 13:53:47 +02:00
Hive& operator=( const Hive& rhs );
2017-08-08 13:53:47 +02:00
public:
Hive();
2017-08-08 13:53:47 +02:00
virtual ~Hive();
2017-08-08 13:53:47 +02:00
// Returns the io_service of this object.
boost::asio::io_service& GetService();
2017-08-08 13:53:47 +02:00
// Returns true if the Stop function has been called.
bool HasStopped();
2017-08-08 13:53:47 +02:00
// Polls the networking subsystem once from the current thread and
// returns.
void Poll();
2017-08-08 13:53:47 +02:00
// Runs the networking system on the current thread. This function blocks
// until the networking system is stopped, so do not call on a single
// threaded application with no other means of being able to call Stop
// unless you code in such logic.
void Run();
2017-08-08 13:53:47 +02:00
// Stops the networking system. All work is finished and no more
// networking interactions will be possible afterwards until Reset is called.
void Stop();
// Restarts the networking system after Stop as been called. A new work
// object is created ad the shutdown flag is cleared.
void Reset();
};
}
2017-08-08 13:53:47 +02:00
}
//-----------------------------------------------------------------------------
#endif