summaryrefslogtreecommitdiffstats
path: root/vespalib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2020-02-27 16:43:55 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2020-02-27 16:49:17 +0000
commit752ced912014457c04d2c3670fd7d8b9eda49fa7 (patch)
tree404a21f60b4df37a1d4e718096eed971bf7522bc /vespalib
parentdda41637e506d6f0fdf88f875350adab2743bd1d (diff)
Add getStats and setTaskLimit to interface to make it easy to swap implementation.
Also make do with ISequenceHandlerInterface.
Diffstat (limited to 'vespalib')
-rw-r--r--vespalib/src/vespa/vespalib/util/blockingthreadstackexecutor.cpp6
-rw-r--r--vespalib/src/vespa/vespalib/util/blockingthreadstackexecutor.h5
-rw-r--r--vespalib/src/vespa/vespalib/util/threadexecutor.h17
-rw-r--r--vespalib/src/vespa/vespalib/util/threadstackexecutorbase.cpp6
-rw-r--r--vespalib/src/vespa/vespalib/util/threadstackexecutorbase.h17
5 files changed, 25 insertions, 26 deletions
diff --git a/vespalib/src/vespa/vespalib/util/blockingthreadstackexecutor.cpp b/vespalib/src/vespa/vespalib/util/blockingthreadstackexecutor.cpp
index 33d6e46a244..b5cf16b4f80 100644
--- a/vespalib/src/vespa/vespalib/util/blockingthreadstackexecutor.cpp
+++ b/vespalib/src/vespa/vespalib/util/blockingthreadstackexecutor.cpp
@@ -39,10 +39,4 @@ BlockingThreadStackExecutor::~BlockingThreadStackExecutor()
cleanup();
}
-void
-BlockingThreadStackExecutor::setTaskLimit(uint32_t taskLimit)
-{
- internalSetTaskLimit(taskLimit);
-}
-
} // namespace vespalib
diff --git a/vespalib/src/vespa/vespalib/util/blockingthreadstackexecutor.h b/vespalib/src/vespa/vespalib/util/blockingthreadstackexecutor.h
index 73a142ae42c..df3f9408e0a 100644
--- a/vespalib/src/vespa/vespalib/util/blockingthreadstackexecutor.h
+++ b/vespalib/src/vespa/vespalib/util/blockingthreadstackexecutor.h
@@ -33,11 +33,6 @@ public:
init_fun_t init_function);
~BlockingThreadStackExecutor();
-
- /**
- * Sets a new upper limit for accepted number of tasks.
- */
- void setTaskLimit(uint32_t taskLimit);
};
} // namespace vespalib
diff --git a/vespalib/src/vespa/vespalib/util/threadexecutor.h b/vespalib/src/vespa/vespalib/util/threadexecutor.h
index 2dcbb595bb3..202e516bc60 100644
--- a/vespalib/src/vespa/vespalib/util/threadexecutor.h
+++ b/vespalib/src/vespa/vespalib/util/threadexecutor.h
@@ -4,6 +4,7 @@
#include "executor.h"
#include "syncable.h"
+#include "executor_stats.h"
namespace vespalib {
@@ -11,10 +12,26 @@ class ThreadExecutor : public Executor
{
public:
/**
+ * Internal stats that we want to observe externally. Note that
+ * all stats are reset each time they are observed.
+ **/
+ using Stats = ExecutorStats;
+ /**
* Get number of threads in the executor pool.
* @return number of threads in the pool
*/
virtual size_t getNumThreads() const = 0;
+
+ /**
+ * Observe and reset stats for this object.
+ * @return stats
+ **/
+ virtual Stats getStats() = 0;
+
+ /**
+ * Sets a new upper limit for accepted number of tasks.
+ */
+ virtual void setTaskLimit(uint32_t taskLimit) = 0;
};
/**
diff --git a/vespalib/src/vespa/vespalib/util/threadstackexecutorbase.cpp b/vespalib/src/vespa/vespalib/util/threadstackexecutorbase.cpp
index e933477bfb9..9ab465841d6 100644
--- a/vespalib/src/vespa/vespalib/util/threadstackexecutorbase.cpp
+++ b/vespalib/src/vespa/vespalib/util/threadstackexecutorbase.cpp
@@ -168,6 +168,12 @@ size_t ThreadStackExecutorBase::getNumThreads() const {
}
void
+ThreadStackExecutorBase::setTaskLimit(uint32_t taskLimit)
+{
+ internalSetTaskLimit(taskLimit);
+}
+
+void
ThreadStackExecutorBase::internalSetTaskLimit(uint32_t taskLimit)
{
MonitorGuard monitor(_monitor);
diff --git a/vespalib/src/vespa/vespalib/util/threadstackexecutorbase.h b/vespalib/src/vespa/vespalib/util/threadstackexecutorbase.h
index 8718b04d2d3..2c0bc56d6df 100644
--- a/vespalib/src/vespa/vespalib/util/threadstackexecutorbase.h
+++ b/vespalib/src/vespa/vespalib/util/threadstackexecutorbase.h
@@ -8,10 +8,8 @@
#include "sync.h"
#include "gate.h"
#include "runnable.h"
-#include <memory>
#include <vector>
#include <functional>
-#include "executor_stats.h"
class FastOS_ThreadPool;
@@ -36,12 +34,6 @@ class ThreadStackExecutorBase : public SyncableThreadExecutor,
public Runnable
{
public:
- /**
- * Internal stats that we want to observe externally. Note that
- * all stats are reset each time they are observed.
- **/
- using Stats = ExecutorStats;
-
using init_fun_t = std::function<int(Runnable&)>;
private:
@@ -204,14 +196,8 @@ public:
**/
size_t num_idle_workers() const;
- /**
- * Observe and reset stats for this object.
- *
- * @return stats
- **/
- Stats getStats();
+ Stats getStats() override;
- // inherited from Executor
Task::UP execute(Task::UP task) override;
/**
@@ -232,6 +218,7 @@ public:
void wait_for_task_count(uint32_t task_count);
size_t getNumThreads() const override;
+ void setTaskLimit(uint32_t taskLimit) override;
/**
* Shut down this executor. This will make this executor reject