diff options
Diffstat (limited to 'searchcore')
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/common/feedtoken.h | 13 | ||||
-rw-r--r-- | searchcore/src/vespa/searchcore/proton/persistenceengine/transport_latch.h | 10 |
2 files changed, 17 insertions, 6 deletions
diff --git a/searchcore/src/vespa/searchcore/proton/common/feedtoken.h b/searchcore/src/vespa/searchcore/proton/common/feedtoken.h index 363886b9f31..cf6c1f5a7e9 100644 --- a/searchcore/src/vespa/searchcore/proton/common/feedtoken.h +++ b/searchcore/src/vespa/searchcore/proton/common/feedtoken.h @@ -9,19 +9,23 @@ namespace proton { typedef std::unique_ptr<storage::spi::Result> ResultUP; +namespace feedtoken { + /** * This class is used by the FeedEngine to encapsulate the necessary information * for an IFeedHandler to perform an async reply to an operation. A unique * instance of this class is passed to every invokation of the IFeedHandler. */ -namespace feedtoken { - class ITransport { public: virtual ~ITransport() { } virtual void send(ResultUP result, bool documentWasFound) = 0; }; +/** + * This holds the result of the feed operation until it is either failed or acked. + * Guarantees that the result is propagated back to the invoker via ITransport interface. + */ class State : public search::IDestructorCallback { public: State(const State &) = delete; @@ -42,6 +46,11 @@ private: bool _documentWasFound; std::atomic<bool> _alreadySent; }; + +/** + * This takes ownership ov the transport object, so that it can be used fully asynchronous + * without invoker needing to hold any state. + */ class OwningState : public State { public: OwningState(std::unique_ptr<ITransport> transport) diff --git a/searchcore/src/vespa/searchcore/proton/persistenceengine/transport_latch.h b/searchcore/src/vespa/searchcore/proton/persistenceengine/transport_latch.h index b3b3bc43aa7..da4e19d3584 100644 --- a/searchcore/src/vespa/searchcore/proton/persistenceengine/transport_latch.h +++ b/searchcore/src/vespa/searchcore/proton/persistenceengine/transport_latch.h @@ -10,8 +10,7 @@ namespace proton { /** - * Implementation of FeedToken::ITransport for handling the async reply for an operation. - * Uses an internal count down latch to keep track the number of outstanding replies. + * Base implementation for merging results from multiple sources. */ class TransportMerger : public feedtoken::ITransport { @@ -29,14 +28,17 @@ private: void mergeWithLock(ResultUP result, bool documentWasFound); std::unique_ptr<std::mutex> _lock; }; + +/** + * Implementation of FeedToken::ITransport for handling the async reply for an operation. + * Uses an internal count down latch to keep track the number of outstanding replies. + */ class TransportLatch : public TransportMerger { private: - using UpdateResult = storage::spi::UpdateResult; using RemoveResult = storage::spi::RemoveResult; vespalib::CountDownLatch _latch; - public: TransportLatch(uint32_t cnt); ~TransportLatch() override; |