mirror of
https://github.com/latentPrion/libspinscale.git
synced 2026-06-23 19:48:32 +00:00
SyncCanceler: Fix visibility; reuse helper method
This commit is contained in:
@@ -35,6 +35,11 @@ namespace sscl {
|
|||||||
class SyncCancelerForAsyncWork
|
class SyncCancelerForAsyncWork
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
struct Resources
|
||||||
|
{
|
||||||
|
bool shouldContinue = false;
|
||||||
|
};
|
||||||
|
|
||||||
SyncCancelerForAsyncWork() = default;
|
SyncCancelerForAsyncWork() = default;
|
||||||
|
|
||||||
void startAcceptingWork()
|
void startAcceptingWork()
|
||||||
@@ -56,9 +61,12 @@ public:
|
|||||||
bool isCancellationRequested()
|
bool isCancellationRequested()
|
||||||
{
|
{
|
||||||
sscl::SpinLock::Guard guard(s.lock);
|
sscl::SpinLock::Guard guard(s.lock);
|
||||||
return !s.rsrc.shouldContinue;
|
return isCancellationRequestedUnlocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isCancellationRequestedUnlocked() const
|
||||||
|
{ return !s.rsrc.shouldContinue; }
|
||||||
|
|
||||||
template<typename Body>
|
template<typename Body>
|
||||||
requires std::invocable<Body>
|
requires std::invocable<Body>
|
||||||
bool execUncancelableSegmentOrAbort(Body&& body)
|
bool execUncancelableSegmentOrAbort(Body&& body)
|
||||||
@@ -71,12 +79,7 @@ public:
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
public:
|
||||||
struct Resources
|
|
||||||
{
|
|
||||||
bool shouldContinue = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
sscl::SharedResourceGroup<sscl::SpinLock, Resources> s;
|
sscl::SharedResourceGroup<sscl::SpinLock, Resources> s;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user