| | |
| | | { |
| | | size_t size = content.size(); |
| | | auto OnResult = [content = std::move(content), msg_id, remote, cb = std::move(cb), this](MsgI &msg) mutable { |
| | | if (!msg.Fill(content)) { return; } |
| | | if (!msg.Fill(content)) { return false; } |
| | | |
| | | try { |
| | | if (!cb) { |
| | |
| | | }; |
| | | Send(remote, msg, onExpireRemoveCB); |
| | | } |
| | | return true; |
| | | } catch (...) { |
| | | SetLastError(eError, "Send internal error."); |
| | | return false; |
| | | } |
| | | }; |
| | | |
| | | #if 0 |
| | | // self alloc |
| | | MsgI msg; |
| | | if (msg.Make(size)) { |
| | | DEFER1(msg.Release()); |
| | | return OnResult(msg); |
| | | } |
| | | #else |
| | | // center alloc |
| | | return RequestAlloc(size, OnResult); |
| | | #endif |
| | | } |
| | | |
| | | bool ShmSocket::RequestAlloc(const int64_t size, std::function<void(MsgI &msg)> const &onResult) |