lichao
2021-04-23 dc86ace85e437ecb8a2e728e4dce36d02bbb8a6e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
 * =====================================================================================
 *
 *       Filename:  failed_msg.cpp
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  2021年04月12日 16时10分53秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Li Chao (), lichao@aiotlink.com
 *   Organization:  
 *
 * =====================================================================================
 */
#include "failed_msg.h"
 
FailedMsgQ::Func FailedMsgQ::PrepareSender(const std::string &remote, Msg msg)
{
    msg.AddRef();
    return [remote, msg](void *valid_sock) mutable {
        assert(valid_sock);
        ShmSocket &sock = *static_cast<ShmSocket *>(valid_sock);
        DEFER1(msg.Release(sock.shm())); // Release() is not const, but it's safe to release.
        return sock.Send(remote.data(), msg);
    };
}