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

58 lines
1.5 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
*/
bool run_alone(const char* addrs, const char* path = NULL);
protected:
master_fiber();
virtual ~master_fiber();
/**
*
* @param stream {socket_stream&}
*
*/
virtual void on_accept(socket_stream& stream) = 0;
/**
* 线
*/
virtual void thread_on_init(void) {}
private:
static void service_on_listen(void*, ACL_VSTREAM*);
static void service_on_accept(void*, ACL_VSTREAM*);
static void service_pre_jail(void*);
static void service_init(void*);
static void thread_init(void*);
static void service_exit(void*);
void run(int argc, char** argv);
};
} // namespace acl