lichao
2021-03-25 3f4f049ac015c695a965142e7b1180eae83ae781
src/shm_queue.cpp
@@ -48,8 +48,6 @@
bool ShmMsgQueue::Send(const MQId &remote_id, const Msg &msg, const int timeout_ms)
{
    Queue *remote = find(MsgQIdToName(remote_id));
    return remote && remote->Write(msg, timeout_ms);
    
    if(!remote) {
        return false;
@@ -65,6 +63,11 @@
bool ShmMsgQueue::Send(const MQId &remote_id, const void *data, const size_t size, const int timeout_ms)
{
    // Test shows that in the 2 cases:
    // 1) build msg first, then find remote queue;
    // 2) find remote queue first, then build msg;
    // 1 is about 50% faster than 2, maybe cache related.
    Msg msg;
    if (msg.Build(shm(), Id(), data, size, false)) {
        if (Send(remote_id, msg, timeout_ms)) {