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

67 lines
1.6 KiB
C++
Raw Normal View History

2017-09-22 12:27:21 +08:00
#pragma once
//#include "acl_cpp/master/master_base.hpp"
struct ACL_VSTREAM;
namespace acl {
class socket_stream;
/**
*
*/
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);
/**
*
* @return {const char*} NULL
*/
const char* get_conf_path(void) const;
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*);
static int service_on_sighup(void*, ACL_VSTRING*);
void run(int argc, char** argv);
};
} // namespace acl