Spinscale: create new namespace sscl
This commit is contained in:
@@ -71,7 +71,7 @@ bool IoUringAssemblyEngine::setup()
|
||||
{
|
||||
// Defensive check to prevent double-calling
|
||||
{
|
||||
SpinLock::Guard lock(shouldAcceptRequestsLock);
|
||||
sscl::SpinLock::Guard lock(shouldAcceptRequestsLock);
|
||||
if (shouldAcceptRequests)
|
||||
{
|
||||
throw std::runtime_error(std::string(__func__) + ": setup() called "
|
||||
@@ -180,7 +180,7 @@ void IoUringAssemblyEngine::finalize()
|
||||
|
||||
{
|
||||
auto& ioService = smoHooksPtr->ComponentThread_getSelf()->getIoService();
|
||||
AsynchronousBridge bridge(ioService);
|
||||
sscl::AsynchronousBridge bridge(ioService);
|
||||
boost::asio::deadline_timer timeoutTimer(ioService);
|
||||
|
||||
/** EXPLANATION:
|
||||
@@ -329,7 +329,7 @@ void IoUringAssemblyEngine::resetAndAssembleFrame(
|
||||
bool IoUringAssemblyEngine::stop()
|
||||
{
|
||||
// Acquire and release lock tightly around setting the flag
|
||||
SpinLock::Guard lock(shouldAcceptRequestsLock);
|
||||
sscl::SpinLock::Guard lock(shouldAcceptRequestsLock);
|
||||
bool wasAcceptingRequests = shouldAcceptRequests;
|
||||
shouldAcceptRequests = false;
|
||||
return wasAcceptingRequests;
|
||||
@@ -427,22 +427,22 @@ cleanup_eventfd:
|
||||
|
||||
// Continuation class for assembleFrameReq
|
||||
class IoUringAssemblyEngine::AssembleFrameReq
|
||||
: public PostedAsynchronousContinuation<
|
||||
: public sscl::PostedAsynchronousContinuation<
|
||||
IoUringAssemblyEngine::assembleFrameReqCbFn>
|
||||
{
|
||||
public:
|
||||
AssembleFrameReq(
|
||||
IoUringAssemblyEngine& engine_,
|
||||
const std::shared_ptr<ComponentThread>& caller,
|
||||
Callback<IoUringAssemblyEngine::assembleFrameReqCbFn> cb)
|
||||
: PostedAsynchronousContinuation<
|
||||
const std::shared_ptr<sscl::ComponentThread>& caller,
|
||||
sscl::Callback<IoUringAssemblyEngine::assembleFrameReqCbFn> cb)
|
||||
: sscl::PostedAsynchronousContinuation<
|
||||
IoUringAssemblyEngine::assembleFrameReqCbFn>(caller, cb),
|
||||
engine(engine_),
|
||||
loop(engine_.frameAssemblyDesc->numSlots),
|
||||
timerFired(false), handlerExecuted(false)
|
||||
{}
|
||||
|
||||
void callOriginalCallback(bool success, AsynchronousLoop loop)
|
||||
void callOriginalCallback(bool success, sscl::AsynchronousLoop loop)
|
||||
{
|
||||
callOriginalCb(success, loop);
|
||||
}
|
||||
@@ -451,16 +451,16 @@ public:
|
||||
void assembleFrameReq1_posted(
|
||||
std::shared_ptr<AssembleFrameReq> context)
|
||||
{
|
||||
SpinLock::Guard lock(engine.shouldAcceptRequestsLock);
|
||||
sscl::SpinLock::Guard lock(engine.shouldAcceptRequestsLock);
|
||||
|
||||
if (!engine.shouldAcceptRequests)
|
||||
{
|
||||
context->callOriginalCallback(false, AsynchronousLoop(0));
|
||||
context->callOriginalCallback(false, sscl::AsynchronousLoop(0));
|
||||
return;
|
||||
}
|
||||
|
||||
// Initialize loop with number of slots
|
||||
context->loop = AsynchronousLoop(engine.frameAssemblyDesc->numSlots);
|
||||
context->loop = sscl::AsynchronousLoop(engine.frameAssemblyDesc->numSlots);
|
||||
|
||||
// Record assembly start time
|
||||
engine.assemblyStartTime = std::chrono::high_resolution_clock::now();
|
||||
@@ -505,7 +505,7 @@ public:
|
||||
* indeed seen a SEGFAULT even in the current code with locking, so
|
||||
* I'm going to hold the lock here for now.
|
||||
*/
|
||||
SpinLock::Guard lock(context->engine.shouldAcceptRequestsLock);
|
||||
sscl::SpinLock::Guard lock(context->engine.shouldAcceptRequestsLock);
|
||||
|
||||
if (!context->engine.shouldAcceptRequests)
|
||||
{
|
||||
@@ -636,19 +636,19 @@ public:
|
||||
|
||||
public:
|
||||
IoUringAssemblyEngine& engine;
|
||||
AsynchronousLoop loop;
|
||||
sscl::AsynchronousLoop loop;
|
||||
std::atomic<bool> timerFired;
|
||||
std::atomic<bool> handlerExecuted;
|
||||
};
|
||||
|
||||
void IoUringAssemblyEngine::assembleFrameReq(
|
||||
Callback<assembleFrameReqCbFn> cb)
|
||||
sscl::Callback<assembleFrameReqCbFn> cb)
|
||||
{
|
||||
{
|
||||
SpinLock::Guard lock(shouldAcceptRequestsLock);
|
||||
sscl::SpinLock::Guard lock(shouldAcceptRequestsLock);
|
||||
if (!shouldAcceptRequests)
|
||||
{
|
||||
cb.callbackFn(false, AsynchronousLoop(0));
|
||||
cb.callbackFn(false, sscl::AsynchronousLoop(0));
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -677,7 +677,7 @@ void IoUringAssemblyEngine::onEventfdRead(
|
||||
* IoUringAssemblyEngine's per-assembly state isn't destroyed while this
|
||||
* handler is running.
|
||||
*/
|
||||
SpinLock::Guard lock(shouldAcceptRequestsLock);
|
||||
sscl::SpinLock::Guard lock(shouldAcceptRequestsLock);
|
||||
/** EXPLANATION:
|
||||
* You'd think we should put check for shouldAcceptRequests here and
|
||||
* `return` here if !shouldAcceptRequests, but we shouldn't because
|
||||
@@ -763,7 +763,7 @@ void IoUringAssemblyEngine::fillUnAssembledSlotsWithDummyDgrams()
|
||||
}
|
||||
}
|
||||
|
||||
void IoUringAssemblyEngine::randomDummySlotFiller(AsynchronousLoop& loop)
|
||||
void IoUringAssemblyEngine::randomDummySlotFiller(sscl::AsynchronousLoop& loop)
|
||||
{
|
||||
if (!frameAssemblyDesc)
|
||||
{ return; }
|
||||
@@ -816,7 +816,7 @@ void IoUringAssemblyEngine::randomDummySlotFiller(AsynchronousLoop& loop)
|
||||
numDummiesToCreate = dummiesCreated;
|
||||
}
|
||||
|
||||
// Update the AsynchronousLoop to reflect the new number of dummies
|
||||
// Update the sscl::AsynchronousLoop to reflect the new number of dummies
|
||||
// Since we only reach here when nSucceeded == nTotal and nFailed == 0,
|
||||
// we can directly calculate the new values
|
||||
uint32_t newSucceeded = nTotal - static_cast<uint32_t>(numDummiesToCreate);
|
||||
|
||||
Reference in New Issue
Block a user