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
|
||||
{
|
||||
public:
|
||||
struct Resources
|
||||
{
|
||||
bool shouldContinue = false;
|
||||
};
|
||||
|
||||
SyncCancelerForAsyncWork() = default;
|
||||
|
||||
void startAcceptingWork()
|
||||
@@ -56,9 +61,12 @@ public:
|
||||
bool isCancellationRequested()
|
||||
{
|
||||
sscl::SpinLock::Guard guard(s.lock);
|
||||
return !s.rsrc.shouldContinue;
|
||||
return isCancellationRequestedUnlocked();
|
||||
}
|
||||
|
||||
bool isCancellationRequestedUnlocked() const
|
||||
{ return !s.rsrc.shouldContinue; }
|
||||
|
||||
template<typename Body>
|
||||
requires std::invocable<Body>
|
||||
bool execUncancelableSegmentOrAbort(Body&& body)
|
||||
@@ -71,12 +79,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
private:
|
||||
struct Resources
|
||||
{
|
||||
bool shouldContinue = false;
|
||||
};
|
||||
|
||||
public:
|
||||
sscl::SharedResourceGroup<sscl::SpinLock, Resources> s;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user