Apollo 技术文档Apollo 技术文档
指南
  • 架构概述
  • BigWorld 架构深度解析
  • BigWorld 进程架构与玩家生命周期
  • AOI九宫格系统详解
  • AOI广播与消息去重
  • Base 模块
  • Core 模块
  • Runtime 模块
  • Data 模块
  • Network 模块
  • /modules/actor.html
  • Game 模块
  • BigWorld 模块
服务器应用
API 参考
QA
GitHub
指南
  • 架构概述
  • BigWorld 架构深度解析
  • BigWorld 进程架构与玩家生命周期
  • AOI九宫格系统详解
  • AOI广播与消息去重
  • Base 模块
  • Core 模块
  • Runtime 模块
  • Data 模块
  • Network 模块
  • /modules/actor.html
  • Game 模块
  • BigWorld 模块
服务器应用
API 参考
QA
GitHub
  • API 参考
  • Base API
  • Core API
  • Runtime API

Runtime API

apollo::runtime::ApplicationHost

namespace apollo::runtime {
class ApplicationHost {
public:
    ApplicationHost();
    ~ApplicationHost();

    // 注册应用
    template<typename T, typename... Args>
    void registerApplication(Args&&... args);

    // 运行
    int run();

    // 停止
    void stop();

    // 是否运行中
    bool is_running() const;

    // 添加关闭钩子
    void addShutdownHook(std::function<void()> hook);
};
}

线程安全: ⚠️ stop() 可以在任何线程调用


apollo::runtime::Console

namespace apollo::runtime {
class Console {
public:
    static Console& instance();

    // 启动控制台监听
    void start();

    // 停止控制台监听
    void stop();

    // 添加命令
    void addCommand(const std::string& name, std::function<void()> handler);

    // 移除命令
    void removeCommand(const std::string& name);
};
}

线程安全: ✅


apollo::runtime::Signal

namespace apollo::runtime {
class Signal {
public:
    static Signal& instance();

    // 注册信号处理器
    void on(int signal, std::function<void()> handler);

    // 忽略信号
    void ignore(int signal);

    // 默认处理
    void default_(int signal);
};
}

线程安全: ⚠️ 信号处理器在信号处理线程执行


apollo::runtime::HealthCheck

namespace apollo::runtime {
class HealthCheck {
public:
    static HealthCheck& instance();

    // 添加检查项
    void add(const std::string& name, std::function<HealthStatus()> checker);

    // 移除检查项
    void remove(const std::string& name);

    // 检查所有
    HealthStatus check();

    // 获取状态
    HealthStatus getStatus(const std::string& name) const;
};

enum class HealthStatus {
    HEALTHY,
    DEGRADED,
    UNHEALTHY
};
}

线程安全: ✅

在 GitHub 上编辑此页
最后更新: 3/20/26, 6:06 AM
贡献者: cuihairu
Prev
API 参考