-
Notifications
You must be signed in to change notification settings - Fork 392
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reason for change: Decouple to avoid lock issues. Test Procedure: None Risks: None Signed-off-by: Nikita Poltorapavlo <[email protected]>
- Loading branch information
1 parent
3d2b6b6
commit 520161a
Showing
8 changed files
with
186 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#pragma once | ||
|
||
#include "../../Module.h" | ||
|
||
class WorkerPoolImplementation : public WPEFramework::Core::WorkerPool, public WPEFramework::Core::ThreadPool::ICallback { | ||
private: | ||
class Dispatcher : public WPEFramework::Core::ThreadPool::IDispatcher { | ||
public: | ||
Dispatcher(const Dispatcher&) = delete; | ||
Dispatcher& operator=(const Dispatcher&) = delete; | ||
|
||
Dispatcher() = default; | ||
~Dispatcher() override = default; | ||
|
||
private: | ||
void Initialize() override | ||
{ | ||
} | ||
void Deinitialize() override | ||
{ | ||
} | ||
void Dispatch(WPEFramework::Core::IDispatch* job) override | ||
{ | ||
job->Dispatch(); | ||
} | ||
}; | ||
|
||
public: | ||
WorkerPoolImplementation() = delete; | ||
WorkerPoolImplementation(const WorkerPoolImplementation&) = delete; | ||
WorkerPoolImplementation& operator=(const WorkerPoolImplementation&) = delete; | ||
|
||
WorkerPoolImplementation(const uint32_t stackSize) | ||
: WPEFramework::Core::WorkerPool(4 /*threadCount*/, stackSize, 32 /*queueSize*/, &_dispatch, this) | ||
, _dispatch() | ||
{ | ||
Run(); | ||
} | ||
~WorkerPoolImplementation() override | ||
{ | ||
Stop(); | ||
} | ||
void Idle() override | ||
{ | ||
} | ||
|
||
private: | ||
Dispatcher _dispatch; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
|
||
#include "../../Module.h" | ||
#include <gmock/gmock.h> | ||
|
||
using ::testing::Test; | ||
|
||
class WorkerPoolTest : public Test { | ||
protected: | ||
WPEFramework::Core::ProxyType<WorkerPoolImplementation> workerPool; | ||
WorkerPoolTest() | ||
: workerPool(WPEFramework::Core::ProxyType<WorkerPoolImplementation>::Create( | ||
WPEFramework::Core::Thread::DefaultStackSize())) | ||
{ | ||
WPEFramework::Core::IWorkerPool::Assign(&(*workerPool)); | ||
} | ||
~WorkerPoolTest() override | ||
{ | ||
WPEFramework::Core::IWorkerPool::Assign(nullptr); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#pragma once | ||
|
||
#include "../../Module.h" | ||
|
||
class WorkerPoolImplementation : public WPEFramework::Core::WorkerPool, public WPEFramework::Core::ThreadPool::ICallback { | ||
private: | ||
class Dispatcher : public WPEFramework::Core::ThreadPool::IDispatcher { | ||
public: | ||
Dispatcher(const Dispatcher&) = delete; | ||
Dispatcher& operator=(const Dispatcher&) = delete; | ||
|
||
Dispatcher() = default; | ||
~Dispatcher() override = default; | ||
|
||
private: | ||
void Initialize() override | ||
{ | ||
} | ||
void Deinitialize() override | ||
{ | ||
} | ||
void Dispatch(WPEFramework::Core::IDispatch* job) override | ||
{ | ||
job->Dispatch(); | ||
} | ||
}; | ||
|
||
public: | ||
WorkerPoolImplementation() = delete; | ||
WorkerPoolImplementation(const WorkerPoolImplementation&) = delete; | ||
WorkerPoolImplementation& operator=(const WorkerPoolImplementation&) = delete; | ||
|
||
WorkerPoolImplementation(const uint32_t stackSize) | ||
: WPEFramework::Core::WorkerPool(4 /*threadCount*/, stackSize, 32 /*queueSize*/, &_dispatch, this) | ||
, _dispatch() | ||
{ | ||
Run(); | ||
} | ||
~WorkerPoolImplementation() override | ||
{ | ||
Stop(); | ||
} | ||
void Idle() override | ||
{ | ||
} | ||
|
||
private: | ||
Dispatcher _dispatch; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#pragma once | ||
|
||
#include "../../Module.h" | ||
#include <gmock/gmock.h> | ||
|
||
using ::testing::Test; | ||
|
||
class WorkerPoolTest : public Test { | ||
protected: | ||
WPEFramework::Core::ProxyType<WorkerPoolImplementation> workerPool; | ||
WorkerPoolTest() | ||
: workerPool(WPEFramework::Core::ProxyType<WorkerPoolImplementation>::Create( | ||
WPEFramework::Core::Thread::DefaultStackSize())) | ||
{ | ||
WPEFramework::Core::IWorkerPool::Assign(&(*workerPool)); | ||
} | ||
~WorkerPoolTest() override | ||
{ | ||
WPEFramework::Core::IWorkerPool::Assign(nullptr); | ||
} | ||
}; |