-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix mask source, minor changes (#123)
* fix: mask source was always acting on all slices * if no file is selected, skip BeginDataexport/EndDataexport in SaveAs/SaveCopyAs * morpho: limit number of threads for running all slices (2d) Co-authored-by: Bryn Lloyd <[email protected]>
- Loading branch information
Showing
4 changed files
with
107 additions
and
30 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright (c) 2021 The Foundation for Research on Information Technologies in Society (IT'IS). | ||
* | ||
* This file is part of iSEG | ||
* (see https://github.com/ITISFoundation/osparc-iseg). | ||
* | ||
* This software is released under the MIT License. | ||
* https://opensource.org/licenses/MIT | ||
*/ | ||
|
||
#pragma once | ||
|
||
namespace iseg { | ||
|
||
/** This simple template class allows to execute arbitrary code when leaving a scope. | ||
\note Instances can only be moved, not copied. | ||
*/ | ||
template <typename F> | ||
struct ScopeExit | ||
{ | ||
explicit ScopeExit(F f) | ||
: f(std::move(f)) | ||
, m_Empty(false) | ||
{} | ||
~ScopeExit() | ||
{ | ||
if (!m_Empty) | ||
f(); | ||
} | ||
|
||
F f; | ||
|
||
ScopeExit(ScopeExit && rhs) noexcept | ||
: f(std::move(rhs.f)) | ||
{ | ||
rhs.m_Empty = true; | ||
m_Empty = false; | ||
} | ||
|
||
private: | ||
ScopeExit(const ScopeExit & rhs) = delete; | ||
void operator=(const ScopeExit & rhs) = delete; | ||
bool m_Empty; | ||
}; | ||
|
||
/// Creates | ||
template <typename F> | ||
ScopeExit<F> MakeScopeExit(F f) | ||
{ | ||
return std::move(ScopeExit<F>(std::move(f))); | ||
}; | ||
|
||
} // namespace iseg |
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