summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2021-08-13 12:45:47 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2021-08-13 12:45:47 +0000
commit1292a3ad898b50de44ae8d2967e9d6de8ab536a3 (patch)
tree45a02bf3bd120fb3b3a993c7ee361ce1e05e7d31
parentce7b0fab632bb4c4332777ab4ce40bf47e136f79 (diff)
Notify when _pending reaches zero.
-rw-r--r--searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp
index 10a82ffe6f6..77e4f665327 100644
--- a/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp
+++ b/searchlib/src/vespa/searchlib/tensor/dense_tensor_attribute.cpp
@@ -229,7 +229,6 @@ public:
_cond.wait(guard);
}
}
- while (_pending > 1000) { std::this_thread::yield(); }
++_pending;
_shared_executor.execute(vespalib::makeLambdaTask([this, ref, lid]() {
auto prepared = _attr._index->prepare_add_document(lid, _attr._denseTensorStore.get_typed_cells(ref), _attr.getGenerationHandler().takeGuard());
@@ -238,7 +237,8 @@ public:
_attr._index->complete_add_document(lid, std::move(result));
{
std::unique_lock guard(_mutex);
- if (--_pending == MAX_PENDING/2) {
+ --_pending;
+ if ((_pending == MAX_PENDING/2) || (_pending == 0)) {
_cond.notify_all();
}
}
@@ -249,7 +249,10 @@ public:
}));
}
void wait_complete() override {
- while (_pending > 0) { std::this_thread::sleep_for(1ms); }
+ std::unique_lock guard(_mutex);
+ while (_pending > 0) {
+ _cond.wait(guard);
+ }
}
private:
static constexpr uint32_t MAX_PENDING = 1000;