aboutsummaryrefslogtreecommitdiffstats
path: root/storage/src/vespa/storage/storageserver/message_dispatcher.h
blob: 349bf4e995654fb964dcef1e7418555c0320d21d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include <memory>

namespace storage {

namespace api { class StorageMessage; }

/**
 * Allows for dispatching messages either as a sync or async operation.
 * Semantics:
 *   - dispatch_sync: no immediate thread handoff; try to process in caller thread if possible
 *   - dispatch_async: guaranteed thread handoff; message not processed in caller thread.
 */
class MessageDispatcher {
public:
    virtual ~MessageDispatcher() = default;

    virtual void dispatch_sync(std::shared_ptr<api::StorageMessage> msg) = 0;
    virtual void dispatch_async(std::shared_ptr<api::StorageMessage> msg) = 0;
};

}