-
-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement parallelism singleton (#901)
- Loading branch information
1 parent
033184b
commit 937ed79
Showing
10 changed files
with
76 additions
and
37 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
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
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,37 @@ | ||
#include "Parallel.hpp" | ||
|
||
struct ParallelState { | ||
// ParallelState is a singleton | ||
ParallelState(const ParallelState&) = delete; | ||
ParallelState& operator=(const ParallelState&) = delete; | ||
ParallelState(ParallelState&&) noexcept = delete; | ||
ParallelState& operator=(ParallelState&&) noexcept = delete; | ||
~ParallelState() noexcept = default; | ||
|
||
void set(const bool isParallel) noexcept { | ||
state = isParallel; | ||
} | ||
bool get() const noexcept { | ||
return state; | ||
} | ||
|
||
static ParallelState& instance() noexcept { | ||
static ParallelState INSTANCE; | ||
return INSTANCE; | ||
} | ||
|
||
private: | ||
bool state = true; | ||
|
||
ParallelState() noexcept = default; | ||
}; | ||
|
||
void | ||
setParallel(const bool isParallel) noexcept { | ||
ParallelState::instance().set(isParallel); | ||
} | ||
|
||
bool | ||
isParallel() noexcept { | ||
return ParallelState::instance().get(); | ||
} |
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,4 @@ | ||
#pragma once | ||
|
||
void setParallel(bool isParallel) noexcept; | ||
bool isParallel() noexcept; |