aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-04-30 13:31:15 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-04-30 13:31:15 +0000
commit704b6635543a6e0b1489f6371de865383575c6e3 (patch)
tree133c64d579995c9e0f083e96e23e4f6351c78f71 /searchcore
parente3da8487f35e6ff4ea65f27ba6f3e1bcb89d32a2 (diff)
Add class comments and resolve PR comments.
Diffstat (limited to 'searchcore')
-rw-r--r--searchcore/src/vespa/searchcore/proton/common/feedtoken.h13
-rw-r--r--searchcore/src/vespa/searchcore/proton/persistenceengine/transport_latch.h10
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;