diff options
author | Henning Baldersheim <balder@oath.com> | 2018-06-17 22:35:07 +0200 |
---|---|---|
committer | Henning Baldersheim <balder@oath.com> | 2018-06-17 22:35:07 +0200 |
commit | 8926abb4432ca8ab0ccae3ee6e9b4f376d37ecbf (patch) | |
tree | 83d4f7131db9fe5b52da1c2cb7f713f034da4875 /searchlib | |
parent | 8076e0074b86d5d4e44bc459593ab1b54f744a7c (diff) |
- Remove the execute(string, ...) and force the use of ExecutorId.
- Remove some double bookkeeping in AttributeWriter.
- Ensure that we always use attribute.getNamePrefix() to compute executor id.
Diffstat (limited to 'searchlib')
-rw-r--r-- | searchlib/src/tests/common/sequencedtaskexecutor/sequencedtaskexecutor_test.cpp | 11 | ||||
-rw-r--r-- | searchlib/src/vespa/searchlib/common/isequencedtaskexecutor.h | 8 |
2 files changed, 9 insertions, 10 deletions
diff --git a/searchlib/src/tests/common/sequencedtaskexecutor/sequencedtaskexecutor_test.cpp b/searchlib/src/tests/common/sequencedtaskexecutor/sequencedtaskexecutor_test.cpp index 805a6d3b962..f8ab03d7710 100644 --- a/searchlib/src/tests/common/sequencedtaskexecutor/sequencedtaskexecutor_test.cpp +++ b/searchlib/src/tests/common/sequencedtaskexecutor/sequencedtaskexecutor_test.cpp @@ -122,8 +122,8 @@ TEST_F("require that task with same string component id are serialized", Fixture std::shared_ptr<TestObj> tv(std::make_shared<TestObj>()); EXPECT_EQUAL(0, tv->_val); auto test2 = [=]() { tv->modify(14, 42); }; - f._threads.execute("0", [=]() { usleep(2000); tv->modify(0, 14); }); - f._threads.execute("0", test2); + f._threads.execute(f._threads.getExecutorId("0"), [=]() { usleep(2000); tv->modify(0, 14); }); + f._threads.execute(f._threads.getExecutorId("0"), test2); tv->wait(2); EXPECT_EQUAL(0, tv->_fail); EXPECT_EQUAL(42, tv->_val); @@ -132,8 +132,7 @@ TEST_F("require that task with same string component id are serialized", Fixture EXPECT_EQUAL(42, tv->_val); } -namespace -{ +namespace { int detectSerializeFailure(Fixture &f, vespalib::stringref altComponentId, int tryLimit) { @@ -141,8 +140,8 @@ int detectSerializeFailure(Fixture &f, vespalib::stringref altComponentId, int t for (tryCnt = 0; tryCnt < tryLimit; ++tryCnt) { std::shared_ptr<TestObj> tv(std::make_shared<TestObj>()); EXPECT_EQUAL(0, tv->_val); - f._threads.execute("0", [=]() { usleep(2000); tv->modify(0, 14); }); - f._threads.execute(altComponentId, [=]() { tv->modify(14, 42); }); + f._threads.execute(f._threads.getExecutorId("0"), [=]() { usleep(2000); tv->modify(0, 14); }); + f._threads.execute(f._threads.getExecutorId(altComponentId), [=]() { tv->modify(14, 42); }); tv->wait(2); if (tv->_fail != 1) { continue; diff --git a/searchlib/src/vespa/searchlib/common/isequencedtaskexecutor.h b/searchlib/src/vespa/searchlib/common/isequencedtaskexecutor.h index 05347e790fb..a8b2a722c01 100644 --- a/searchlib/src/vespa/searchlib/common/isequencedtaskexecutor.h +++ b/searchlib/src/vespa/searchlib/common/isequencedtaskexecutor.h @@ -89,14 +89,14 @@ public: * call sync before tearing down pointed to/referenced data. * All tasks must be scheduled from same thread. * - * @param componentId component id - * @param function function to be wrapped in a task and later executed + * @param id executor id + * @param function function to be wrapped in a task and later executed */ template <class FunctionType> - void execute(vespalib::stringref componentId, FunctionType &&function) { - ExecutorId id = getExecutorId(componentId); + void execute(ExecutorId id, FunctionType &&function) { executeTask(id, vespalib::makeLambdaTask(std::forward<FunctionType>(function))); } + }; } // namespace search |