summaryrefslogtreecommitdiffstats
path: root/fastos
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-12-19 16:06:16 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2022-12-20 05:10:52 +0000
commita00e560b0d8267e9b376e5c0e6a2139a7be63281 (patch)
treeba207915b8cac9fb92493cc103821f6cce9db31b /fastos
parent05b58ac83b06b00ae97ecafad101e44d4dd76aee (diff)
Remove stacksize from the thread pools and thread executors.
Diffstat (limited to 'fastos')
-rw-r--r--fastos/src/tests/thread_joinwait_test.cpp5
-rw-r--r--fastos/src/tests/thread_stats_test.cpp2
-rw-r--r--fastos/src/tests/threadtest.cpp12
-rw-r--r--fastos/src/vespa/fastos/thread.cpp4
-rw-r--r--fastos/src/vespa/fastos/thread.h11
5 files changed, 15 insertions, 19 deletions
diff --git a/fastos/src/tests/thread_joinwait_test.cpp b/fastos/src/tests/thread_joinwait_test.cpp
index fc96b49f926..a26501fef01 100644
--- a/fastos/src/tests/thread_joinwait_test.cpp
+++ b/fastos/src/tests/thread_joinwait_test.cpp
@@ -17,7 +17,7 @@ class Thread_JoinWait_Test : public ThreadTestBase
sprintf(testName, "Single Thread Join Wait Multiple Test %d", variant);
TestHeader(testName);
- FastOS_ThreadPool pool(128*1024);
+ FastOS_ThreadPool pool;
const int testThreads=5;
int lastThreadNum = testThreads-1;
@@ -35,8 +35,7 @@ class Thread_JoinWait_Test : public ThreadTestBase
{
jobs[i].code = WAIT_FOR_THREAD_TO_FINISH;
jobs[i].mutex = &jobMutex;
- jobs[i].ownThread = pool.NewThread(this,
- static_cast<void *>(&jobs[i]));
+ jobs[i].ownThread = pool.NewThread(this, static_cast<void *>(&jobs[i]));
rc = (jobs[i].ownThread != nullptr);
Progress(rc, "Creating Thread %d", i+1);
diff --git a/fastos/src/tests/thread_stats_test.cpp b/fastos/src/tests/thread_stats_test.cpp
index 6559513f7ff..40c1199135c 100644
--- a/fastos/src/tests/thread_stats_test.cpp
+++ b/fastos/src/tests/thread_stats_test.cpp
@@ -14,7 +14,7 @@ class Thread_Stats_Test : public ThreadTestBase
TestHeader("Thread Statistics Test");
- FastOS_ThreadPool pool(128*1024);
+ FastOS_ThreadPool pool;
Job job[2];
inactiveThreads = pool.GetNumInactiveThreads();
diff --git a/fastos/src/tests/threadtest.cpp b/fastos/src/tests/threadtest.cpp
index 968779019cb..34723e4edce 100644
--- a/fastos/src/tests/threadtest.cpp
+++ b/fastos/src/tests/threadtest.cpp
@@ -19,7 +19,7 @@ class ThreadTest : public ThreadTestBase
{
TestHeader("Too Many Threads Test");
- FastOS_ThreadPool *pool = new FastOS_ThreadPool(128*1024, MAX_THREADS);
+ FastOS_ThreadPool *pool = new FastOS_ThreadPool(MAX_THREADS);
if (Progress(pool != nullptr, "Allocating ThreadPool")) {
int i;
@@ -62,7 +62,7 @@ class ThreadTest : public ThreadTestBase
{
TestHeader("Create Single Thread And Join Test");
- FastOS_ThreadPool *pool = new FastOS_ThreadPool(128*1024);
+ FastOS_ThreadPool *pool = new FastOS_ThreadPool;
if (Progress(pool != nullptr, "Allocating ThreadPool")) {
Job job;
@@ -93,7 +93,7 @@ class ThreadTest : public ThreadTestBase
if (!silent)
TestHeader("Thread Create Performance");
- FastOS_ThreadPool *pool = new FastOS_ThreadPool(128 * 1024);
+ FastOS_ThreadPool *pool = new FastOS_ThreadPool;
if (!silent)
Progress(pool != nullptr, "Allocating ThreadPool");
@@ -166,7 +166,7 @@ class ThreadTest : public ThreadTestBase
{
TestHeader("Close Pool Test");
- FastOS_ThreadPool pool(128*1024);
+ FastOS_ThreadPool pool;
const int closePoolThreads=9;
Job jobs[closePoolThreads];
@@ -188,7 +188,7 @@ class ThreadTest : public ThreadTestBase
void BreakFlagTest () {
TestHeader("BreakFlag Test");
- FastOS_ThreadPool pool(128*1024);
+ FastOS_ThreadPool pool;
const int breakFlagThreads=4;
@@ -212,7 +212,7 @@ class ThreadTest : public ThreadTestBase
TestHeader ("Thread Id Test");
- FastOS_ThreadPool pool(128*1024);
+ FastOS_ThreadPool pool;
Job jobs[numThreads];
std::mutex slowStartMutex;
diff --git a/fastos/src/vespa/fastos/thread.cpp b/fastos/src/vespa/fastos/thread.cpp
index 3850c14fb26..9a9c3321cac 100644
--- a/fastos/src/vespa/fastos/thread.cpp
+++ b/fastos/src/vespa/fastos/thread.cpp
@@ -14,7 +14,9 @@
// FastOS_ThreadPool
// ----------------------------------------------------------------------
-FastOS_ThreadPool::FastOS_ThreadPool(int , int maxThreads)
+FastOS_ThreadPool::FastOS_ThreadPool() : FastOS_ThreadPool(0) {}
+
+FastOS_ThreadPool::FastOS_ThreadPool(int maxThreads)
: _startedThreadsCount(0),
_closeFlagMutex(),
_closeCalledFlag(false),
diff --git a/fastos/src/vespa/fastos/thread.h b/fastos/src/vespa/fastos/thread.h
index d42987640b4..2fb717403f2 100644
--- a/fastos/src/vespa/fastos/thread.h
+++ b/fastos/src/vespa/fastos/thread.h
@@ -131,14 +131,9 @@ private:
public:
FastOS_ThreadPool(const FastOS_ThreadPool&) = delete;
FastOS_ThreadPool& operator=(const FastOS_ThreadPool&) = delete;
- /**
- * Create a threadpool that can hold a maximum of [maxThreads] threads.
- * @param stackSize The stack size for threads in this pool should
- * be this many bytes.
- * @param maxThreads Maximum number of threads in threadpool.
- * (0 == no limit).
- */
- FastOS_ThreadPool(int stackSize, int maxThreads=0);
+ FastOS_ThreadPool(int maxThreads);
+ /// Unlimited threads
+ FastOS_ThreadPool();
/**
* Destructor. Closes pool if necessary.