Skip to content

Commit d90ba56

Browse files
committed
Refactor: Move limited_concurrency_task to executor
This allows it to be used by other parties than ep-engine Change-Id: I9d159e07ca635d9af2e636d3478ae0140654addc Reviewed-on: https://review.couchbase.org/c/kv_engine/+/190163 Tested-by: Trond Norbye <[email protected]> Reviewed-by: Jim Walker <[email protected]>
1 parent 577ff77 commit d90ba56

File tree

6 files changed

+23
-6
lines changed

6 files changed

+23
-6
lines changed

engines/ep/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,6 @@ ADD_LIBRARY(ep_objs OBJECT
378378
src/kv_bucket.cc
379379
src/kvshard.cc
380380
src/learning_age_and_mfu_based_eviction.cc
381-
src/limited_concurrency_task.cc
382381
src/memory_tracker.cc
383382
src/mutation_log.cc
384383
src/mutation_log_entry.cc

engines/ep/src/tasks.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,8 @@
1313

1414
#include "kvstore/kvstore.h"
1515
#include <executor/globaltask.h>
16+
#include <executor/limited_concurrency_task.h>
1617
#include <memcached/storeddockey.h>
17-
18-
#include "limited_concurrency_task.h"
19-
2018
#include <array>
2119
#include <chrono>
2220
#include <optional>

engines/ep/tests/module_tests/task_concurrency_test.cc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111

1212
#include "task_concurrency_test.h"
1313

14-
#include "limited_concurrency_task.h"
15-
1614
#include "../mock/mock_synchronous_ep_engine.h"
15+
#include <executor/limited_concurrency_task.h>
1716
#include <platform/awaitable_semaphore.h>
1817
#include <platform/semaphore_guard.h>
1918

executor/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ add_library(mcd_executor STATIC
1212
futurequeue.h
1313
globaltask.cc
1414
globaltask.h
15+
limited_concurrency_task.cc
16+
limited_concurrency_task.h
1517
mock_executor_pool.cc
1618
mock_executor_pool.h
1719
notifiable_task.cc
File renamed without changes.

engines/ep/src/limited_concurrency_task.h renamed to executor/limited_concurrency_task.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,25 @@
4343
*/
4444
class LimitedConcurrencyTask : public cb::Waiter, public NotifiableTask {
4545
public:
46+
/**
47+
* Construct a task which will be concurrency limited by the provided
48+
* semaphore.
49+
*
50+
* @param t The taskable owning the task
51+
* @param id task id
52+
* @param semaphore semphore from which a token must be acquired before the
53+
* task can run
54+
* @param completeBeforeShutdown should the task be required to complete
55+
* before shutdown
56+
*/
57+
LimitedConcurrencyTask(Taskable& t,
58+
TaskId id,
59+
cb::AwaitableSemaphore& semaphore,
60+
bool completeBeforeShutdown)
61+
: NotifiableTask(t, id, 0, completeBeforeShutdown),
62+
semaphore(semaphore) {
63+
}
64+
4665
/**
4766
* Construct a task which will be concurrency limited by the provided
4867
* semaphore.

0 commit comments

Comments
 (0)