Skip to content

Commit 62b1dfd

Browse files
committed
MB-36956: Move CB3ExecutorThread to own files
Move the CB3ExecutorThread class from executorthread.{cc,h} to it's own cb3_executorthread.{cc,h} files. Change-Id: I7871ae8cafc1861a650a86a85315c718c39f11b6 Reviewed-on: http://review.couchbase.org/c/kv_engine/+/133514 Tested-by: Build Bot <[email protected]> Reviewed-by: Jim Walker <[email protected]>
1 parent 3158c9b commit 62b1dfd

File tree

9 files changed

+25
-20
lines changed

9 files changed

+25
-20
lines changed

engines/ep/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,7 @@ ADD_LIBRARY(ep_objs OBJECT
237237
src/bucket_logger.cc
238238
src/callbacks.cc
239239
src/cb3_executorpool.cc
240+
src/cb3_executorthread.cc
240241
src/checkpoint.cc
241242
src/checkpoint_config.cc
242243
src/checkpoint_manager.cc
@@ -293,7 +294,6 @@ ADD_LIBRARY(ep_objs OBJECT
293294
src/ephemeral_vb_count_visitor.cc
294295
src/environment.cc
295296
src/executorpool.cc
296-
src/executorthread.cc
297297
src/ext_meta_parser.cc
298298
src/failover-table.cc
299299
src/flusher.cc

engines/ep/src/bgfetcher.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
#include "bgfetcher.h"
1919
#include "bucket_logger.h"
20+
#include "cb3_executorthread.h"
2021
#include "ep_engine.h"
2122
#include "executorpool.h"
22-
#include "executorthread.h"
2323
#include "kv_bucket.h"
2424
#include "kvshard.h"
2525
#include "tasks.h"

engines/ep/src/cb3_executorpool.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
#include "cb3_executorpool.h"
1919
#include "bucket_logger.h"
20+
#include "cb3_executorthread.h"
2021
#include "ep_engine.h"
2122
#include "ep_time.h"
22-
#include "executorthread.h"
2323
#include "statistics/collector.h"
2424
#include "taskqueue.h"
2525

engines/ep/src/executorthread.cc renamed to engines/ep/src/cb3_executorthread.cc

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
#include "executorthread.h"
18+
#include "cb3_executorthread.h"
1919
#include "bucket_logger.h"
2020
#include "cb3_executorpool.h"
2121
#include "globaltask.h"
@@ -29,10 +29,10 @@
2929
#include <sstream>
3030

3131
extern "C" {
32-
static void launch_executor_thread(void *arg) {
33-
auto* executor = (CB3ExecutorThread*)arg;
34-
executor->run();
35-
}
32+
static void launch_executor_thread(void* arg) {
33+
auto* executor = (CB3ExecutorThread*)arg;
34+
executor->run();
35+
}
3636
}
3737

3838
CB3ExecutorThread::~CB3ExecutorThread() {
@@ -48,7 +48,10 @@ void CB3ExecutorThread::start() {
4848
thread_name.replace(pos, worker.size(), "");
4949
}
5050
thread_name.resize(15);
51-
if (cb_create_named_thread(&thread, launch_executor_thread, this, 0,
51+
if (cb_create_named_thread(&thread,
52+
launch_executor_thread,
53+
this,
54+
0,
5255
thread_name.c_str()) != 0) {
5356
std::stringstream ss;
5457
ss << name.c_str() << ": Initialization error!!!";
@@ -118,13 +121,12 @@ void CB3ExecutorThread::run() {
118121
priority = getpriority(PRIO_PROCESS, 0);
119122

120123
for (uint8_t tick = 1;; tick++) {
121-
122124
if (state != EXECUTOR_RUNNING) {
123125
break;
124126
}
125127

126128
updateCurrentTime();
127-
if (TaskQueue *q = manager->nextTask(*this, tick)) {
129+
if (TaskQueue* q = manager->nextTask(*this, tick)) {
128130
manager->startWork(taskType);
129131

130132
if (currentTask->isdead()) {

engines/ep/src/executorthread.h renamed to engines/ep/src/cb3_executorthread.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,15 @@ enum executor_state_t {
4444
class CB3ExecutorThread {
4545
friend class CB3ExecutorPool;
4646
friend class TaskQueue;
47+
4748
public:
4849
/* The AtomicProcessTime class provides an abstraction for ensuring that
4950
* changes to a std::chrono::steady_clock::time_point are atomic. This is
5051
* achieved by ensuring that all accesses are protected by a mutex.
5152
*/
5253
class AtomicProcessTime {
5354
public:
54-
AtomicProcessTime() {}
55+
AtomicProcessTime() = default;
5556
explicit AtomicProcessTime(
5657
const std::chrono::steady_clock::time_point& tp)
5758
: timepoint(tp) {
@@ -90,11 +91,11 @@ class CB3ExecutorThread {
9091

9192
void run();
9293

93-
void stop(bool wait=true);
94+
void stop(bool wait = true);
9495

95-
void schedule(ExTask &task);
96+
void schedule(ExTask& task);
9697

97-
void wake(ExTask &task);
98+
void wake(ExTask& task);
9899

99100
// Changes this threads' current task to the specified task
100101
void setCurrentTask(ExTask newTask);
@@ -104,7 +105,9 @@ class CB3ExecutorThread {
104105
*/
105106
void resetCurrentTask();
106107

107-
const std::string& getName() const { return name; }
108+
const std::string& getName() const {
109+
return name;
110+
}
108111

109112
std::string getTaskName();
110113

engines/ep/src/fakes/fake_executorpool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#pragma once
3030

3131
#include "cb3_executorpool.h"
32-
#include "executorthread.h"
32+
#include "cb3_executorthread.h"
3333
#include "objectregistry.h"
3434
#include "taskqueue.h"
3535

engines/ep/src/flusher.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717
#pragma once
1818

19-
#include "executorthread.h"
19+
#include "cb3_executorthread.h"
2020
#include "utility.h"
2121
#include "vb_ready_queue.h"
2222

engines/ep/src/taskqueue.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "taskqueue.h"
1818
#include "bucket_logger.h"
1919
#include "cb3_executorpool.h"
20-
#include "executorthread.h"
20+
#include "cb3_executorthread.h"
2121

2222
#include <cmath>
2323

engines/ep/tests/module_tests/executorpool_test.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
#pragma once
2323

2424
#include "../mock/mock_taskable.h"
25+
#include "cb3_executorthread.h"
2526
#include "executorpool.h"
26-
#include "executorthread.h"
2727
#include "fakes/fake_executorpool.h"
2828
#include "taskable.h"
2929
#include "thread_gate.h"

0 commit comments

Comments
 (0)