zhangmeng
2022-12-26 9045f528b9b6f21f0d15475d2dffd49bb51598fc
optimize cpu
2个文件已修改
14 ■■■■■ 已修改文件
src/nng_wrap.cpp 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/nng_wrap.h 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/nng_wrap.cpp
@@ -590,20 +590,22 @@
    if (!w) return -1;
    *src = malloc(sizeof(uint64_t));
    *(uint64_t*)(*src) = key;
    *src = malloc(sizeof(key));
    memcpy(*src, &key, sizeof(key));
    return w->mode;
}
int send_reply(const void* src, const void* msg, const int msg_len, void* arg/*=NULL*/){
int send_reply(void* src, const void* msg, const int msg_len, void* arg/*=NULL*/){
    _rr* rep = (_rr*)arg;
    if (!rep) rep = singleton<_rr>();
    struct work* w{};
    {
        auto key = *(static_cast<uint64_t*>(const_cast<void*>(src)));
        free(const_cast<void*>(src));
        uint64_t key;
        memcpy(&key, src, sizeof(key));
        // auto key = *(static_cast<uint64_t*>(const_cast<void*>(src)));
        free(src);
        lock_guard<mutex> l{rep->mtx_msg_};
        auto iter = rep->works_.find(key);
src/nng_wrap.h
@@ -28,7 +28,7 @@
    void** reply, int* reply_len, const int to_ms, void* arg=NULL);
int start_reply(const std::string& url, const int port, void* arg=NULL);
int read_request(void** src, std::string* msg, const int to_ms, void* arg=NULL);
int send_reply(const void* src, const void* msg, const int msg_len, void* arg=NULL);
int send_reply(void* src, const void* msg, const int msg_len, void* arg=NULL);
}