compaction_manager: introduce can_submit

Purpose is to reuse code and also make it easier to read.

Signed-off-by: Raphael S. Carvalho <raphaelsc@scylladb.com>
This commit is contained in:
Raphael S. Carvalho
2016-01-21 15:39:24 -02:00
parent 653a07d75d
commit bb909798bc
2 changed files with 10 additions and 2 deletions

View File

@@ -254,8 +254,12 @@ void compaction_manager::signal_less_busy_task() {
(*result)->compaction_sem.signal();
}
bool compaction_manager::can_submit() {
return !_stopped && !_tasks.empty();
}
void compaction_manager::submit(column_family* cf) {
if (_stopped || _tasks.empty()) {
if (!can_submit()) {
return;
}
// To avoid having two or more entries of the same cf stored in the queue.
@@ -268,7 +272,7 @@ void compaction_manager::submit(column_family* cf) {
}
void compaction_manager::submit_cleanup_job(column_family* cf) {
if (_stopped || _tasks.empty()) {
if (!can_submit()) {
return;
}
// To avoid having two or more entries of the same cf stored in the queue.

View File

@@ -82,6 +82,10 @@ private:
// This function is called when a cf is submitted for compaction and we need
// to wake up a handler.
void signal_less_busy_task();
// Returns if this compaction manager is accepting new requests.
// It will not accept new requests in case the manager was stopped and/or there
// is no task to handle them.
bool can_submit();
public:
compaction_manager();
~compaction_manager();