acl/lib_fiber/cpp/include/fiber/master_fiber.hpp

51 lines
1.4 KiB
C++
Raw Normal View History

#pragma once
#include "acl_cpp/acl_cpp_define.hpp"
#include "acl_cpp/master/master_base.hpp"
#include "acl_cpp/stream/socket_stream.hpp"
namespace acl {
/**
*
*/
class master_fiber : public master_base
{
public:
/**
* acl_master
* @param argc {int}
* @param argv {char**}
*/
void run_daemon(int argc, char** argv);
/**
*
* @param addrs {const char*}
* ip:port, ip:port, ...
* @param path {const char*} NULL
* @param count {unsigned int}
*/
bool run_alone(const char* addrs, const char* path = NULL,
unsigned int count = 0);
protected:
master_fiber();
virtual ~master_fiber();
/**
*
* @param stream {socket_stream&}
*
*/
virtual void on_accept(socket_stream& stream) = 0;
private:
static void service_on_listen(ACL_VSTREAM*);
static void service_on_accept(ACL_VSTREAM*, void*);
static void service_pre_jail(void*);
static void service_init(void*);
static void service_exit(void*);
};
} // namespace acl