Spinscale: create new namespace sscl

This commit is contained in:
2025-12-27 16:21:22 -04:00
parent 0c4f427c0a
commit 34d76df7d9
67 changed files with 434 additions and 429 deletions
@@ -92,7 +92,7 @@ void StimulusProducer::destroyAttachedStimulusBuffer(
void StimulusProducer::stop() void StimulusProducer::stop()
{ {
{ {
SpinLock::Guard lock(shouldContinueLock); sscl::SpinLock::Guard lock(shouldContinueLock);
shouldContinue = false; shouldContinue = false;
} }
@@ -131,7 +131,7 @@ void StimulusProducer::onTimeout(const boost::system::error_code& error)
return; return;
} }
SpinLock::Guard lock(shouldContinueLock); sscl::SpinLock::Guard lock(shouldContinueLock);
if (!shouldContinue) if (!shouldContinue)
{ return; } { return; }
+4 -4
View File
@@ -10,7 +10,7 @@ namespace livoxProto1 {
namespace comms { namespace comms {
BroadcastListener::BroadcastListener( BroadcastListener::BroadcastListener(
const std::shared_ptr<smo::ComponentThread>& componentThread, const std::shared_ptr<sscl::ComponentThread>& componentThread,
uint16_t listeningPort, uint16_t connectPort uint16_t listeningPort, uint16_t connectPort
) )
: componentThread(componentThread), : componentThread(componentThread),
@@ -94,7 +94,7 @@ void BroadcastListener::broadcastMsgInd(
reinterpret_cast<const char*>(msg->broadcast_code)); reinterpret_cast<const char*>(msg->broadcast_code));
// Early return if device already exists // Early return if device already exists
smo::SpinLock::Guard lock(isListeningLock); sscl::SpinLock::Guard lock(isListeningLock);
if (deviceExists(broadcastCode)) if (deviceExists(broadcastCode))
{ {
@@ -134,7 +134,7 @@ void BroadcastListener::start(void)
* away. * away.
*/ */
{ {
smo::SpinLock::Guard lock(isListeningLock); sscl::SpinLock::Guard lock(isListeningLock);
socket.open(boost::asio::ip::udp::v4()); socket.open(boost::asio::ip::udp::v4());
socket.bind(listeningEndpoint); socket.bind(listeningEndpoint);
@@ -172,7 +172,7 @@ void BroadcastListener::startReceive(void)
void BroadcastListener::stop(void) void BroadcastListener::stop(void)
{ {
{ {
smo::SpinLock::Guard lock(isListeningLock); sscl::SpinLock::Guard lock(isListeningLock);
if (!isListening) { return; } if (!isListening) { return; }
isListening = false; isListening = false;
+3 -3
View File
@@ -29,7 +29,7 @@ class BroadcastListener
{ {
public: public:
BroadcastListener( BroadcastListener(
const std::shared_ptr<smo::ComponentThread>& componentThread, const std::shared_ptr<sscl::ComponentThread>& componentThread,
uint16_t listeningPort=55000, uint16_t connectPort=65000); uint16_t listeningPort=55000, uint16_t connectPort=65000);
~BroadcastListener() = default; ~BroadcastListener() = default;
@@ -54,7 +54,7 @@ private:
void startReceive(void); void startReceive(void);
private: private:
std::shared_ptr<smo::ComponentThread> componentThread; std::shared_ptr<sscl::ComponentThread> componentThread;
/** EXPLANATION: /** EXPLANATION:
* The Livox proto says that client devices will spam broadcast UDP * The Livox proto says that client devices will spam broadcast UDP
* dgrams to us on the listening port. We can then use the source IP from * dgrams to us on the listening port. We can then use the source IP from
@@ -68,7 +68,7 @@ private:
boost::asio::ip::udp::socket socket; boost::asio::ip::udp::socket socket;
boost::asio::ip::udp::endpoint listeningEndpoint, senderEndpoint; boost::asio::ip::udp::endpoint listeningEndpoint, senderEndpoint;
smo::SpinLock isListeningLock; sscl::SpinLock isListeningLock;
bool isListening; bool isListening;
uint8_t bcastMsgRecvBuffer[UDP_BCAST_MSG_BUFFER_NBYTES]; uint8_t bcastMsgRecvBuffer[UDP_BCAST_MSG_BUFFER_NBYTES];
+10 -10
View File
@@ -74,7 +74,7 @@ std::optional<std::shared_ptr<Device>> DeviceManager::getDevice(
// GetOrCreateDeviceReq nested class implementation // GetOrCreateDeviceReq nested class implementation
class DeviceManager::GetOrCreateDeviceReq class DeviceManager::GetOrCreateDeviceReq
: public smo::NonPostedAsynchronousContinuation< : public sscl::NonPostedAsynchronousContinuation<
livoxProto1_getOrCreateDeviceReqCbFn> livoxProto1_getOrCreateDeviceReqCbFn>
{ {
public: public:
@@ -86,8 +86,8 @@ public:
GetOrCreateDeviceReq( GetOrCreateDeviceReq(
DeviceManager& mgr, DeviceManager& mgr,
std::shared_ptr<Device> device, std::shared_ptr<Device> device,
smo::Callback<livoxProto1_getOrCreateDeviceReqCbFn> cb) sscl::Callback<livoxProto1_getOrCreateDeviceReqCbFn> cb)
: smo::NonPostedAsynchronousContinuation< : sscl::NonPostedAsynchronousContinuation<
livoxProto1_getOrCreateDeviceReqCbFn>(std::move(cb)), livoxProto1_getOrCreateDeviceReqCbFn>(std::move(cb)),
deviceManager(mgr), pendingDevice(device) deviceManager(mgr), pendingDevice(device)
{} {}
@@ -128,11 +128,11 @@ public:
void DeviceManager::getOrCreateDeviceReq( void DeviceManager::getOrCreateDeviceReq(
const std::string &deviceIdentifier, const std::string &deviceIdentifier,
const std::shared_ptr<smo::ComponentThread>& componentThread, const std::shared_ptr<sscl::ComponentThread>& componentThread,
int commandTimeoutMs, int retryDelayMs, int commandTimeoutMs, int retryDelayMs,
const std::string& smoIp, uint8_t smoSubnetNbits, const std::string& smoIp, uint8_t smoSubnetNbits,
uint16_t dataPort, uint16_t cmdPort, uint16_t imuPort, uint16_t dataPort, uint16_t cmdPort, uint16_t imuPort,
smo::Callback<livoxProto1_getOrCreateDeviceReqCbFn> callback) sscl::Callback<livoxProto1_getOrCreateDeviceReqCbFn> callback)
{ {
// Validate smoIp format using Boost.Asio IPv4 validation // Validate smoIp format using Boost.Asio IPv4 validation
if (!smoIp.empty() && !comms::isValidIPv4(smoIp)) if (!smoIp.empty() && !comms::isValidIPv4(smoIp))
@@ -179,7 +179,7 @@ void DeviceManager::getOrCreateDeviceReq(
} }
class DeviceManager::DestroyDeviceReq class DeviceManager::DestroyDeviceReq
: public smo::NonPostedAsynchronousContinuation< : public sscl::NonPostedAsynchronousContinuation<
livoxProto1_destroyDeviceReqCbFn> livoxProto1_destroyDeviceReqCbFn>
{ {
public: public:
@@ -190,8 +190,8 @@ public:
DestroyDeviceReq( DestroyDeviceReq(
DeviceManager& mgr, DeviceManager& mgr,
std::shared_ptr<Device> device, std::shared_ptr<Device> device,
smo::Callback<livoxProto1_destroyDeviceReqCbFn> cb) sscl::Callback<livoxProto1_destroyDeviceReqCbFn> cb)
: smo::NonPostedAsynchronousContinuation< : sscl::NonPostedAsynchronousContinuation<
livoxProto1_destroyDeviceReqCbFn>(std::move(cb)), livoxProto1_destroyDeviceReqCbFn>(std::move(cb)),
deviceManager(mgr), pendingDevice(device) deviceManager(mgr), pendingDevice(device)
{} {}
@@ -220,7 +220,7 @@ public:
void DeviceManager::destroyDeviceReq( void DeviceManager::destroyDeviceReq(
std::shared_ptr<Device> dev, std::shared_ptr<Device> dev,
smo::Callback<livoxProto1_destroyDeviceReqCbFn> callback sscl::Callback<livoxProto1_destroyDeviceReqCbFn> callback
) )
{ {
/** EXPLANATION: /** EXPLANATION:
@@ -245,7 +245,7 @@ void DeviceManager::destroyDeviceReq(
request.get(), request, std::placeholders::_1)}); request.get(), request, std::placeholders::_1)});
} }
void main(const std::shared_ptr<smo::ComponentThread> &componentThread, void main(const std::shared_ptr<sscl::ComponentThread> &componentThread,
const smo::stim_buff::SmoCallbacks& smoCallbacks) const smo::stim_buff::SmoCallbacks& smoCallbacks)
{ {
if (protoState.isInitialized) { if (protoState.isInitialized) {
+5 -5
View File
@@ -25,15 +25,15 @@ public:
void getOrCreateDeviceReq( void getOrCreateDeviceReq(
const std::string &deviceIdentifier, const std::string &deviceIdentifier,
const std::shared_ptr<smo::ComponentThread>& componentThread, const std::shared_ptr<sscl::ComponentThread>& componentThread,
int commandTimeoutMs, int retryDelayMs, int commandTimeoutMs, int retryDelayMs,
const std::string& smoIp, uint8_t smoSubnetNbits, const std::string& smoIp, uint8_t smoSubnetNbits,
uint16_t dataPort, uint16_t cmdPort, uint16_t imuPort, uint16_t dataPort, uint16_t cmdPort, uint16_t imuPort,
smo::Callback<livoxProto1_getOrCreateDeviceReqCbFn> callback); sscl::Callback<livoxProto1_getOrCreateDeviceReqCbFn> callback);
void destroyDeviceReq( void destroyDeviceReq(
std::shared_ptr<Device> device, std::shared_ptr<Device> device,
smo::Callback<livoxProto1_destroyDeviceReqCbFn> callback); sscl::Callback<livoxProto1_destroyDeviceReqCbFn> callback);
std::optional<std::shared_ptr<Device>> getDevice( std::optional<std::shared_ptr<Device>> getDevice(
const std::string &deviceIdentifier); const std::string &deviceIdentifier);
@@ -59,7 +59,7 @@ public:
}; };
void main( void main(
const std::shared_ptr<smo::ComponentThread> &componentThread, const std::shared_ptr<sscl::ComponentThread> &componentThread,
const smo::stim_buff::SmoCallbacks& smoCallbacks); const smo::stim_buff::SmoCallbacks& smoCallbacks);
void exit(void); void exit(void);
@@ -67,7 +67,7 @@ void exit(void);
struct ProtoState struct ProtoState
{ {
bool isInitialized = false; bool isInitialized = false;
std::shared_ptr<smo::ComponentThread> componentThread; std::shared_ptr<sscl::ComponentThread> componentThread;
std::unique_ptr<DeviceManager> deviceManager; std::unique_ptr<DeviceManager> deviceManager;
smo::stim_buff::SmoCallbacks smoCallbacks; smo::stim_buff::SmoCallbacks smoCallbacks;
}; };
+41 -41
View File
@@ -90,7 +90,7 @@ std::string DiscoveredDevice::getDeviceTypeName(void) const
} // namespace comms } // namespace comms
Device::Device(const std::string &deviceIdentifier, Device::Device(const std::string &deviceIdentifier,
const std::shared_ptr<smo::ComponentThread>& componentThread, const std::shared_ptr<sscl::ComponentThread>& componentThread,
int commandTimeoutMs, int retryDelayMs, int commandTimeoutMs, int retryDelayMs,
const std::string& smoIp, uint8_t smoSubnetNbits, const std::string& smoIp, uint8_t smoSubnetNbits,
uint16_t dataPort, uint16_t cmdPort, uint16_t imuPort) uint16_t dataPort, uint16_t cmdPort, uint16_t imuPort)
@@ -124,15 +124,15 @@ Device::~Device()
* This class manages the overall device connection process including handshake and heartbeat setup * This class manages the overall device connection process including handshake and heartbeat setup
*/ */
class Device::ConnectReq class Device::ConnectReq
: public smo::NonPostedAsynchronousContinuation<Device::connectReqCbFn> : public sscl::NonPostedAsynchronousContinuation<Device::connectReqCbFn>
{ {
private: private:
Device& device; Device& device;
boost::asio::deadline_timer delayTimer; boost::asio::deadline_timer delayTimer;
public: public:
ConnectReq(Device& dev, smo::Callback<Device::connectReqCbFn> cb) ConnectReq(Device& dev, sscl::Callback<Device::connectReqCbFn> cb)
: smo::NonPostedAsynchronousContinuation<Device::connectReqCbFn>( : sscl::NonPostedAsynchronousContinuation<Device::connectReqCbFn>(
std::move(cb)), device(dev), std::move(cb)), device(dev),
delayTimer(dev.componentThread->getIoService()) delayTimer(dev.componentThread->getIoService())
{} {}
@@ -216,7 +216,7 @@ public:
{ callOriginalCallback(false); } { callOriginalCallback(false); }
}; };
void Device::connectReq(smo::Callback<Device::connectReqCbFn> callback) void Device::connectReq(sscl::Callback<Device::connectReqCbFn> callback)
{ {
// Create the connection request object to hold state and callbacks // Create the connection request object to hold state and callbacks
auto request = std::make_shared<ConnectReq>(*this, std::move(callback)); auto request = std::make_shared<ConnectReq>(*this, std::move(callback));
@@ -233,7 +233,7 @@ void Device::connectReq(smo::Callback<Device::connectReqCbFn> callback)
} }
class Device::ConnectToKnownDeviceReq class Device::ConnectToKnownDeviceReq
: public smo::NonPostedAsynchronousContinuation< : public sscl::NonPostedAsynchronousContinuation<
Device::connectToKnownDeviceReqCbFn> Device::connectToKnownDeviceReqCbFn>
{ {
public: public:
@@ -241,8 +241,8 @@ public:
std::string deviceIP; std::string deviceIP;
std::shared_ptr<livoxProto1::comms::DiscoveredDevice> deviceInfo; std::shared_ptr<livoxProto1::comms::DiscoveredDevice> deviceInfo;
ConnectToKnownDeviceReq(Device& dev, smo::Callback<Device::connectToKnownDeviceReqCbFn> cb) ConnectToKnownDeviceReq(Device& dev, sscl::Callback<Device::connectToKnownDeviceReqCbFn> cb)
: smo::NonPostedAsynchronousContinuation< : sscl::NonPostedAsynchronousContinuation<
Device::connectToKnownDeviceReqCbFn>(std::move(cb)), device(dev) Device::connectToKnownDeviceReqCbFn>(std::move(cb)), device(dev)
{} {}
@@ -269,7 +269,7 @@ public:
* broadcastListener. * broadcastListener.
*/ */
void Device::connectToKnownDeviceReq( void Device::connectToKnownDeviceReq(
smo::Callback<Device::connectToKnownDeviceReqCbFn> callback sscl::Callback<Device::connectToKnownDeviceReqCbFn> callback
) )
{ {
// Create the connection request object to hold state and callbacks // Create the connection request object to hold state and callbacks
@@ -336,7 +336,7 @@ void Device::connectToKnownDeviceReq(
} }
class Device::ConnectByDeviceIdentifierReq class Device::ConnectByDeviceIdentifierReq
: public smo::NonPostedAsynchronousContinuation< : public sscl::NonPostedAsynchronousContinuation<
Device::connectByDeviceIdentifierReqCbFn> Device::connectByDeviceIdentifierReqCbFn>
{ {
public: public:
@@ -344,8 +344,8 @@ public:
std::string deviceIP; std::string deviceIP;
ConnectByDeviceIdentifierReq( ConnectByDeviceIdentifierReq(
Device& dev, smo::Callback<Device::connectByDeviceIdentifierReqCbFn> cb) Device& dev, sscl::Callback<Device::connectByDeviceIdentifierReqCbFn> cb)
: smo::NonPostedAsynchronousContinuation< : sscl::NonPostedAsynchronousContinuation<
Device::connectByDeviceIdentifierReqCbFn>( Device::connectByDeviceIdentifierReqCbFn>(
std::move(cb)), device(dev) std::move(cb)), device(dev)
{} {}
@@ -370,7 +370,7 @@ public:
}; };
void Device::connectByDeviceIdentifierReq( void Device::connectByDeviceIdentifierReq(
smo::Callback<Device::connectByDeviceIdentifierReqCbFn> callback sscl::Callback<Device::connectByDeviceIdentifierReqCbFn> callback
) )
{ {
/** EXPLANATION: /** EXPLANATION:
@@ -419,13 +419,13 @@ void Device::connectByDeviceIdentifierReq(
} }
class Device::ExecuteHandshakeReq class Device::ExecuteHandshakeReq
: public smo::NonPostedAsynchronousContinuation< : public sscl::NonPostedAsynchronousContinuation<
Device::executeHandshakeReqCbFn> Device::executeHandshakeReqCbFn>
{ {
public: public:
friend void Device::executeHandshakeReq( friend void Device::executeHandshakeReq(
const std::string& deviceIP, const std::string& deviceIP,
smo::Callback<Device::executeHandshakeReqCbFn> callback); sscl::Callback<Device::executeHandshakeReqCbFn> callback);
enum class SocketState enum class SocketState
{ {
@@ -459,8 +459,8 @@ public:
Device& dev, const std::string& deviceIP, Device& dev, const std::string& deviceIP,
std::shared_ptr<boost::asio::posix::stream_descriptor> std::shared_ptr<boost::asio::posix::stream_descriptor>
&cmdEndpointFdDesc, &cmdEndpointFdDesc,
smo::Callback<Device::executeHandshakeReqCbFn> cb) sscl::Callback<Device::executeHandshakeReqCbFn> cb)
: smo::NonPostedAsynchronousContinuation<Device::executeHandshakeReqCbFn>( : sscl::NonPostedAsynchronousContinuation<Device::executeHandshakeReqCbFn>(
std::move(cb)), std::move(cb)),
device(dev), deviceIP(deviceIP), device(dev), deviceIP(deviceIP),
cmdEndpointFdDesc(cmdEndpointFdDesc), cmdEndpointFdDesc(cmdEndpointFdDesc),
@@ -753,7 +753,7 @@ private:
void Device::executeHandshakeReq( void Device::executeHandshakeReq(
const std::string& deviceIP, const std::string& deviceIP,
smo::Callback<Device::executeHandshakeReqCbFn> callback sscl::Callback<Device::executeHandshakeReqCbFn> callback
) )
{ {
// Get the command endpoint from the UdpCommandDemuxer // Get the command endpoint from the UdpCommandDemuxer
@@ -803,7 +803,7 @@ void Device::executeHandshakeReq(
} }
} }
void Device::disconnectReq(smo::Callback<Device::disconnectReqCbFn> callback) void Device::disconnectReq(sscl::Callback<Device::disconnectReqCbFn> callback)
{ {
// Stop heartbeat first // Stop heartbeat first
stopHeartbeat(); stopHeartbeat();
@@ -1042,7 +1042,7 @@ void Device::startHeartbeat()
} }
// Register heartbeat ACK handler (cmd_set=0x00, cmd_id=0x03) // Register heartbeat ACK handler (cmd_set=0x00, cmd_id=0x03)
smo::SpinLock::Guard lock(heartbeatActiveLock); sscl::SpinLock::Guard lock(heartbeatActiveLock);
registerUdpCommandHandler( registerUdpCommandHandler(
0x00, 0x03, discardHeartbeatAck, discoveredDevice.ipAddr); 0x00, 0x03, discardHeartbeatAck, discoveredDevice.ipAddr);
@@ -1060,7 +1060,7 @@ void Device::startHeartbeat()
void Device::stopHeartbeat() void Device::stopHeartbeat()
{ {
{ {
smo::SpinLock::Guard lock(heartbeatActiveLock); sscl::SpinLock::Guard lock(heartbeatActiveLock);
heartbeatActive.store(false); heartbeatActive.store(false);
unregisterUdpCommandHandler(0x00, 0x03, discoveredDevice.ipAddr); unregisterUdpCommandHandler(0x00, 0x03, discoveredDevice.ipAddr);
@@ -1168,7 +1168,7 @@ void Device::onHeartbeatTimer(const boost::system::error_code& error)
// Send next heartbeat // Send next heartbeat
{ {
smo::SpinLock::Guard lock(heartbeatActiveLock); sscl::SpinLock::Guard lock(heartbeatActiveLock);
if (!heartbeatActive.load()) if (!heartbeatActive.load())
{ return; } { return; }
@@ -1331,7 +1331,7 @@ std::optional<std::string> Device::getSmoIp(const std::string& deviceIP)
// Base class for both enable and disable pcloud data requests // Base class for both enable and disable pcloud data requests
template<typename CallbackType> template<typename CallbackType>
class EnDisablePcloudDataReq class EnDisablePcloudDataReq
: public smo::NonPostedAsynchronousContinuation<CallbackType> : public sscl::NonPostedAsynchronousContinuation<CallbackType>
{ {
public: public:
enum class SocketState enum class SocketState
@@ -1362,8 +1362,8 @@ public:
protected: protected:
EnDisablePcloudDataReq( EnDisablePcloudDataReq(
Device& dev, Device& dev,
smo::Callback<CallbackType> cb) sscl::Callback<CallbackType> cb)
: smo::NonPostedAsynchronousContinuation<CallbackType>(std::move(cb)), : sscl::NonPostedAsynchronousContinuation<CallbackType>(std::move(cb)),
device(dev), device(dev),
timeoutTimer(device.componentThread->getIoService()) timeoutTimer(device.componentThread->getIoService())
{} {}
@@ -1608,11 +1608,11 @@ class Device::EnablePcloudDataReq
{ {
public: public:
friend void Device::enablePcloudDataReq( friend void Device::enablePcloudDataReq(
smo::Callback<Device::enablePcloudDataReqCbFn> callback); sscl::Callback<Device::enablePcloudDataReqCbFn> callback);
EnablePcloudDataReq( EnablePcloudDataReq(
Device& dev, Device& dev,
smo::Callback<Device::enablePcloudDataReqCbFn> cb) sscl::Callback<Device::enablePcloudDataReqCbFn> cb)
: EnDisablePcloudDataReq<Device::enablePcloudDataReqCbFn>(dev, std::move(cb)) : EnDisablePcloudDataReq<Device::enablePcloudDataReqCbFn>(dev, std::move(cb))
{} {}
@@ -1643,11 +1643,11 @@ class Device::DisablePcloudDataReq
{ {
public: public:
friend void Device::disablePcloudDataReq( friend void Device::disablePcloudDataReq(
smo::Callback<Device::disablePcloudDataReqCbFn> callback); sscl::Callback<Device::disablePcloudDataReqCbFn> callback);
DisablePcloudDataReq( DisablePcloudDataReq(
Device& dev, Device& dev,
smo::Callback<Device::disablePcloudDataReqCbFn> cb) sscl::Callback<Device::disablePcloudDataReqCbFn> cb)
: EnDisablePcloudDataReq<Device::disablePcloudDataReqCbFn>( : EnDisablePcloudDataReq<Device::disablePcloudDataReqCbFn>(
dev, std::move(cb)) dev, std::move(cb))
{} {}
@@ -1675,7 +1675,7 @@ private:
}; };
void Device::enablePcloudDataReq( void Device::enablePcloudDataReq(
smo::Callback<Device::enablePcloudDataReqCbFn> callback sscl::Callback<Device::enablePcloudDataReqCbFn> callback
) )
{ {
auto request = std::make_shared<EnablePcloudDataReq>( auto request = std::make_shared<EnablePcloudDataReq>(
@@ -1702,7 +1702,7 @@ void Device::enablePcloudDataReq(
} }
void Device::disablePcloudDataReq( void Device::disablePcloudDataReq(
smo::Callback<Device::disablePcloudDataReqCbFn> callback sscl::Callback<Device::disablePcloudDataReqCbFn> callback
) )
{ {
auto request = std::make_shared<DisablePcloudDataReq>( auto request = std::make_shared<DisablePcloudDataReq>(
@@ -1858,7 +1858,7 @@ void Device::unregisterUdpCommandHandler(
// SetReturnModeReq continuation class // SetReturnModeReq continuation class
class Device::SetReturnModeReq class Device::SetReturnModeReq
: public smo::NonPostedAsynchronousContinuation<Device::setReturnModeReqCbFn> : public sscl::NonPostedAsynchronousContinuation<Device::setReturnModeReqCbFn>
{ {
public: public:
enum class SocketState enum class SocketState
@@ -1890,12 +1890,12 @@ public:
public: public:
friend void Device::setReturnModeReq( friend void Device::setReturnModeReq(
uint8_t returnMode, uint8_t returnMode,
smo::Callback<Device::setReturnModeReqCbFn> callback); sscl::Callback<Device::setReturnModeReqCbFn> callback);
SetReturnModeReq( SetReturnModeReq(
Device& dev, uint8_t mode, Device& dev, uint8_t mode,
smo::Callback<Device::setReturnModeReqCbFn> cb) sscl::Callback<Device::setReturnModeReqCbFn> cb)
: smo::NonPostedAsynchronousContinuation<Device::setReturnModeReqCbFn>( : sscl::NonPostedAsynchronousContinuation<Device::setReturnModeReqCbFn>(
std::move(cb)), std::move(cb)),
device(dev), returnMode(mode), device(dev), returnMode(mode),
timeoutTimer(device.componentThread->getIoService()) timeoutTimer(device.componentThread->getIoService())
@@ -2107,7 +2107,7 @@ public:
// GetReturnModeReq continuation class // GetReturnModeReq continuation class
class Device::GetReturnModeReq class Device::GetReturnModeReq
: public smo::NonPostedAsynchronousContinuation<Device::getReturnModeReqCbFn> : public sscl::NonPostedAsynchronousContinuation<Device::getReturnModeReqCbFn>
{ {
public: public:
enum class SocketState enum class SocketState
@@ -2137,12 +2137,12 @@ public:
public: public:
friend void Device::getReturnModeReq( friend void Device::getReturnModeReq(
smo::Callback<Device::getReturnModeReqCbFn> callback); sscl::Callback<Device::getReturnModeReqCbFn> callback);
GetReturnModeReq( GetReturnModeReq(
Device& dev, Device& dev,
smo::Callback<Device::getReturnModeReqCbFn> cb) sscl::Callback<Device::getReturnModeReqCbFn> cb)
: smo::NonPostedAsynchronousContinuation<Device::getReturnModeReqCbFn>( : sscl::NonPostedAsynchronousContinuation<Device::getReturnModeReqCbFn>(
std::move(cb)), std::move(cb)),
device(dev), device(dev),
timeoutTimer(device.componentThread->getIoService()) timeoutTimer(device.componentThread->getIoService())
@@ -2351,7 +2351,7 @@ public:
void Device::setReturnModeReq( void Device::setReturnModeReq(
uint8_t returnMode, uint8_t returnMode,
smo::Callback<Device::setReturnModeReqCbFn> callback sscl::Callback<Device::setReturnModeReqCbFn> callback
) )
{ {
auto request = std::make_shared<SetReturnModeReq>( auto request = std::make_shared<SetReturnModeReq>(
@@ -2378,7 +2378,7 @@ void Device::setReturnModeReq(
} }
void Device::getReturnModeReq( void Device::getReturnModeReq(
smo::Callback<Device::getReturnModeReqCbFn> callback sscl::Callback<Device::getReturnModeReqCbFn> callback
) )
{ {
auto request = std::make_shared<GetReturnModeReq>( auto request = std::make_shared<GetReturnModeReq>(
+12 -12
View File
@@ -77,7 +77,7 @@ class Device
{ {
public: public:
Device(const std::string &deviceIdentifier, Device(const std::string &deviceIdentifier,
const std::shared_ptr<smo::ComponentThread>& componentThread, const std::shared_ptr<sscl::ComponentThread>& componentThread,
int commandTimeoutMs, int retryDelayMs, int commandTimeoutMs, int retryDelayMs,
const std::string& smoIp, uint8_t smoSubnetNbits, const std::string& smoIp, uint8_t smoSubnetNbits,
uint16_t dataPort, uint16_t cmdPort, uint16_t imuPort); uint16_t dataPort, uint16_t cmdPort, uint16_t imuPort);
@@ -163,27 +163,27 @@ public:
getReturnModeReqCbFn; getReturnModeReqCbFn;
// Async connection methods // Async connection methods
void connectReq(smo::Callback<connectReqCbFn> callback); void connectReq(sscl::Callback<connectReqCbFn> callback);
void connectToKnownDeviceReq( void connectToKnownDeviceReq(
smo::Callback<connectToKnownDeviceReqCbFn> callback); sscl::Callback<connectToKnownDeviceReqCbFn> callback);
void connectByDeviceIdentifierReq( void connectByDeviceIdentifierReq(
smo::Callback<connectByDeviceIdentifierReqCbFn> callback); sscl::Callback<connectByDeviceIdentifierReqCbFn> callback);
void executeHandshakeReq( void executeHandshakeReq(
const std::string& deviceIP, const std::string& deviceIP,
smo::Callback<executeHandshakeReqCbFn> callback); sscl::Callback<executeHandshakeReqCbFn> callback);
void disconnectReq(smo::Callback<disconnectReqCbFn> callback); void disconnectReq(sscl::Callback<disconnectReqCbFn> callback);
void enablePcloudDataReq(smo::Callback<enablePcloudDataReqCbFn> callback); void enablePcloudDataReq(sscl::Callback<enablePcloudDataReqCbFn> callback);
void disablePcloudDataReq(smo::Callback<disablePcloudDataReqCbFn> callback); void disablePcloudDataReq(sscl::Callback<disablePcloudDataReqCbFn> callback);
void setReturnModeReq( void setReturnModeReq(
uint8_t returnMode, smo::Callback<setReturnModeReqCbFn> callback); uint8_t returnMode, sscl::Callback<setReturnModeReqCbFn> callback);
void getReturnModeReq(smo::Callback<getReturnModeReqCbFn> callback); void getReturnModeReq(sscl::Callback<getReturnModeReqCbFn> callback);
public: public:
comms::DiscoveredDevice discoveredDevice; comms::DiscoveredDevice discoveredDevice;
std::atomic<size_t> nAttachedStimulusProducers; std::atomic<size_t> nAttachedStimulusProducers;
// Configuration // Configuration
std::shared_ptr<smo::ComponentThread> componentThread; std::shared_ptr<sscl::ComponentThread> componentThread;
int commandTimeoutMs, retryDelayMs; int commandTimeoutMs, retryDelayMs;
std::string smoIp; std::string smoIp;
std::string detectedSmoListeningIp; std::string detectedSmoListeningIp;
@@ -193,7 +193,7 @@ public:
// Heartbeat state // Heartbeat state
std::unique_ptr<boost::asio::deadline_timer> heartbeatTimer; std::unique_ptr<boost::asio::deadline_timer> heartbeatTimer;
std::atomic<bool> heartbeatActive; std::atomic<bool> heartbeatActive;
smo::SpinLock heartbeatActiveLock; sscl::SpinLock heartbeatActiveLock;
// Point cloud data state // Point cloud data state
std::atomic<bool> pcloudDataActive; std::atomic<bool> pcloudDataActive;
+7 -7
View File
@@ -12,11 +12,11 @@ extern "C" {
void livoxProto1_getOrCreateDeviceReq( void livoxProto1_getOrCreateDeviceReq(
const std::string& deviceIdentifier, const std::string& deviceIdentifier,
const std::shared_ptr<smo::ComponentThread>& componentThread, const std::shared_ptr<sscl::ComponentThread>& componentThread,
int commandTimeoutMs, int retryDelayMs, int commandTimeoutMs, int retryDelayMs,
const std::string& smoIp, uint8_t smoSubnetNbits, const std::string& smoIp, uint8_t smoSubnetNbits,
uint16_t dataPort, uint16_t cmdPort, uint16_t imuPort, uint16_t dataPort, uint16_t cmdPort, uint16_t imuPort,
smo::Callback<livoxProto1_getOrCreateDeviceReqCbFn> callback sscl::Callback<livoxProto1_getOrCreateDeviceReqCbFn> callback
) )
{ {
// Get the global DeviceManager instance // Get the global DeviceManager instance
@@ -39,7 +39,7 @@ void livoxProto1_getOrCreateDeviceReq(
void livoxProto1_destroyDeviceReq( void livoxProto1_destroyDeviceReq(
std::shared_ptr<livoxProto1::Device> device, std::shared_ptr<livoxProto1::Device> device,
smo::Callback<livoxProto1_destroyDeviceReqCbFn> callback sscl::Callback<livoxProto1_destroyDeviceReqCbFn> callback
) )
{ {
auto& protoState = livoxProto1::getProtoState(); auto& protoState = livoxProto1::getProtoState();
@@ -54,7 +54,7 @@ void livoxProto1_destroyDeviceReq(
} }
void livoxProto1_main( void livoxProto1_main(
const std::shared_ptr<smo::ComponentThread>& componentThread, const std::shared_ptr<sscl::ComponentThread>& componentThread,
const smo::stim_buff::SmoCallbacks& smoCallbacks) const smo::stim_buff::SmoCallbacks& smoCallbacks)
{ {
livoxProto1::main(componentThread, smoCallbacks); livoxProto1::main(componentThread, smoCallbacks);
@@ -67,7 +67,7 @@ void livoxProto1_exit(void)
void livoxProto1_device_enablePcloudDataReq( void livoxProto1_device_enablePcloudDataReq(
std::shared_ptr<livoxProto1::Device> device, std::shared_ptr<livoxProto1::Device> device,
smo::Callback<livoxProto1_device_enablePcloudDataReqCbFn> callback sscl::Callback<livoxProto1_device_enablePcloudDataReqCbFn> callback
) )
{ {
if (!device) if (!device)
@@ -81,7 +81,7 @@ void livoxProto1_device_enablePcloudDataReq(
void livoxProto1_device_disablePcloudDataReq( void livoxProto1_device_disablePcloudDataReq(
std::shared_ptr<livoxProto1::Device> device, std::shared_ptr<livoxProto1::Device> device,
smo::Callback<livoxProto1_device_disablePcloudDataReqCbFn> callback sscl::Callback<livoxProto1_device_disablePcloudDataReqCbFn> callback
) )
{ {
if (!device) if (!device)
@@ -95,7 +95,7 @@ void livoxProto1_device_disablePcloudDataReq(
void livoxProto1_device_getReturnModeReq( void livoxProto1_device_getReturnModeReq(
std::shared_ptr<livoxProto1::Device> device, std::shared_ptr<livoxProto1::Device> device,
smo::Callback<livoxProto1_device_getReturnModeReqCbFn> callback sscl::Callback<livoxProto1_device_getReturnModeReqCbFn> callback
) )
{ {
if (!device) if (!device)
+9 -7
View File
@@ -14,6 +14,8 @@ namespace smo {
namespace stim_buff { namespace stim_buff {
struct SmoCallbacks; struct SmoCallbacks;
} }
}
namespace sscl {
class ComponentThread; class ComponentThread;
} }
@@ -31,7 +33,7 @@ extern "C" {
* @param smoCallbacks Callbacks provided by SMO * @param smoCallbacks Callbacks provided by SMO
*/ */
typedef void livoxProto1_mainFn( typedef void livoxProto1_mainFn(
const std::shared_ptr<smo::ComponentThread>& componentThread, const std::shared_ptr<sscl::ComponentThread>& componentThread,
const smo::stim_buff::SmoCallbacks& smoCallbacks); const smo::stim_buff::SmoCallbacks& smoCallbacks);
/** /**
@@ -58,34 +60,34 @@ typedef std::function<
typedef void livoxProto1_getOrCreateDeviceReqFn( typedef void livoxProto1_getOrCreateDeviceReqFn(
const std::string& deviceIdentifier, const std::string& deviceIdentifier,
const std::shared_ptr<smo::ComponentThread>& componentThread, const std::shared_ptr<sscl::ComponentThread>& componentThread,
int commandTimeoutMs, int retryDelayMs, int commandTimeoutMs, int retryDelayMs,
const std::string& smoIp, uint8_t smoSubnetNbits, const std::string& smoIp, uint8_t smoSubnetNbits,
uint16_t dataPort, uint16_t cmdPort, uint16_t imuPort, uint16_t dataPort, uint16_t cmdPort, uint16_t imuPort,
smo::Callback<livoxProto1_getOrCreateDeviceReqCbFn> callback); sscl::Callback<livoxProto1_getOrCreateDeviceReqCbFn> callback);
typedef std::function<void(bool success)> livoxProto1_destroyDeviceReqCbFn; typedef std::function<void(bool success)> livoxProto1_destroyDeviceReqCbFn;
typedef void livoxProto1_destroyDeviceReqFn( typedef void livoxProto1_destroyDeviceReqFn(
std::shared_ptr<livoxProto1::Device> device, std::shared_ptr<livoxProto1::Device> device,
smo::Callback<livoxProto1_destroyDeviceReqCbFn> callback); sscl::Callback<livoxProto1_destroyDeviceReqCbFn> callback);
typedef std::function<void(bool success)> typedef std::function<void(bool success)>
livoxProto1_device_enablePcloudDataReqCbFn; livoxProto1_device_enablePcloudDataReqCbFn;
typedef void livoxProto1_device_enablePcloudDataReqFn( typedef void livoxProto1_device_enablePcloudDataReqFn(
std::shared_ptr<livoxProto1::Device> device, std::shared_ptr<livoxProto1::Device> device,
smo::Callback<livoxProto1_device_enablePcloudDataReqCbFn> callback); sscl::Callback<livoxProto1_device_enablePcloudDataReqCbFn> callback);
typedef std::function<void(bool success)> typedef std::function<void(bool success)>
livoxProto1_device_disablePcloudDataReqCbFn; livoxProto1_device_disablePcloudDataReqCbFn;
typedef void livoxProto1_device_disablePcloudDataReqFn( typedef void livoxProto1_device_disablePcloudDataReqFn(
std::shared_ptr<livoxProto1::Device> device, std::shared_ptr<livoxProto1::Device> device,
smo::Callback<livoxProto1_device_disablePcloudDataReqCbFn> callback); sscl::Callback<livoxProto1_device_disablePcloudDataReqCbFn> callback);
typedef std::function<void(bool success, uint8_t returnMode)> typedef std::function<void(bool success, uint8_t returnMode)>
livoxProto1_device_getReturnModeReqCbFn; livoxProto1_device_getReturnModeReqCbFn;
typedef void livoxProto1_device_getReturnModeReqFn( typedef void livoxProto1_device_getReturnModeReqFn(
std::shared_ptr<livoxProto1::Device> device, std::shared_ptr<livoxProto1::Device> device,
smo::Callback<livoxProto1_device_getReturnModeReqCbFn> callback); sscl::Callback<livoxProto1_device_getReturnModeReqCbFn> callback);
typedef std::shared_ptr<boost::asio::posix::stream_descriptor> typedef std::shared_ptr<boost::asio::posix::stream_descriptor>
livoxProto1_getPcloudDataFdDescFn(void); livoxProto1_getPcloudDataFdDescFn(void);
+4 -4
View File
@@ -16,7 +16,7 @@ namespace livoxProto1 {
namespace comms { namespace comms {
UdpCommandDemuxer::UdpCommandDemuxer( UdpCommandDemuxer::UdpCommandDemuxer(
const std::shared_ptr<smo::ComponentThread> &componentThread, const std::shared_ptr<sscl::ComponentThread> &componentThread,
DeviceManager &deviceManager, DeviceManager &deviceManager,
uint16_t commandPort, uint16_t commandPort,
uint16_t dataPort uint16_t dataPort
@@ -44,7 +44,7 @@ void UdpCommandDemuxer::start()
try try
{ {
{ {
smo::SpinLock::Guard lock(isActiveAndShouldStopLock); sscl::SpinLock::Guard lock(isActiveAndShouldStopLock);
setupSockets(); setupSockets();
isActive.store(true); isActive.store(true);
@@ -71,7 +71,7 @@ void UdpCommandDemuxer::start()
void UdpCommandDemuxer::stop() void UdpCommandDemuxer::stop()
{ {
{ {
smo::SpinLock::Guard lock(isActiveAndShouldStopLock); sscl::SpinLock::Guard lock(isActiveAndShouldStopLock);
if (!isActive.load()) if (!isActive.load())
{ return; } { return; }
@@ -291,7 +291,7 @@ void UdpCommandDemuxer::onDataReady(const boost::system::error_code &error)
return; return;
} }
smo::SpinLock::Guard lock(isActiveAndShouldStopLock); sscl::SpinLock::Guard lock(isActiveAndShouldStopLock);
if (!isActive.load() || shouldStop.load()) if (!isActive.load() || shouldStop.load())
{ return; } { return; }
+3 -3
View File
@@ -37,7 +37,7 @@ class UdpCommandDemuxer
{ {
public: public:
UdpCommandDemuxer( UdpCommandDemuxer(
const std::shared_ptr<smo::ComponentThread>& componentThread, const std::shared_ptr<sscl::ComponentThread>& componentThread,
DeviceManager& deviceManager, DeviceManager& deviceManager,
uint16_t commandPort = 56001, uint16_t commandPort = 56001,
uint16_t dataPort = 56000); uint16_t dataPort = 56000);
@@ -76,13 +76,13 @@ private:
void onDataReady(const boost::system::error_code& error); void onDataReady(const boost::system::error_code& error);
void processIncomingData(); void processIncomingData();
std::shared_ptr<smo::ComponentThread> componentThread; std::shared_ptr<sscl::ComponentThread> componentThread;
DeviceManager& deviceManager; DeviceManager& deviceManager;
uint16_t commandPort; uint16_t commandPort;
uint16_t dataPort; uint16_t dataPort;
// State management // State management
smo::SpinLock isActiveAndShouldStopLock; sscl::SpinLock isActiveAndShouldStopLock;
std::atomic<bool> isActive{false}; std::atomic<bool> isActive{false};
std::atomic<bool> shouldStop{false}; std::atomic<bool> shouldStop{false};
+7 -8
View File
@@ -10,6 +10,7 @@
#include <preprocessor.h> #include <preprocessor.h>
#include <user/deviceAttachmentSpec.h> #include <user/deviceAttachmentSpec.h>
#include <spinscale/callback.h> #include <spinscale/callback.h>
#include <spinscale/componentThread.h>
#define CL_TARGET_OPENCL_VERSION 120 #define CL_TARGET_OPENCL_VERSION 120
#include <CL/cl.h> #include <CL/cl.h>
@@ -17,8 +18,6 @@ class OptionParser;
namespace smo { namespace smo {
class ComponentThread;
namespace compute { namespace compute {
class ClBuffer; class ClBuffer;
class ComputeDevice; class ComputeDevice;
@@ -45,7 +44,7 @@ struct SmoThreadingModelDesc
* done on the ComponentThread for the thread that SMO provided in the * done on the ComponentThread for the thread that SMO provided in the
* attachDeviceReq call. * attachDeviceReq call.
*/ */
std::shared_ptr<ComponentThread> componentThread; std::shared_ptr<sscl::ComponentThread> componentThread;
}; };
typedef std::function<void(bool, std::shared_ptr<device::DeviceAttachmentSpec>)> typedef std::function<void(bool, std::shared_ptr<device::DeviceAttachmentSpec>)>
@@ -57,11 +56,11 @@ typedef int (sal_mlo_initializeIndFn)(void);
typedef int (sal_mlo_finalizeIndFn)(void); typedef int (sal_mlo_finalizeIndFn)(void);
typedef void (sal_mlo_attachDeviceReqFn)( typedef void (sal_mlo_attachDeviceReqFn)(
const std::shared_ptr<device::DeviceAttachmentSpec>& desc, const std::shared_ptr<device::DeviceAttachmentSpec>& desc,
const std::shared_ptr<ComponentThread>& componentThread, const std::shared_ptr<sscl::ComponentThread>& componentThread,
Callback<sal_mlo_attachDeviceReqCbFn> cb); sscl::Callback<sal_mlo_attachDeviceReqCbFn> cb);
typedef void (sal_mlo_detachDeviceReqFn)( typedef void (sal_mlo_detachDeviceReqFn)(
const std::shared_ptr<device::DeviceAttachmentSpec>& desc, const std::shared_ptr<device::DeviceAttachmentSpec>& desc,
Callback<sal_mlo_detachDeviceReqCbFn> cb); sscl::Callback<sal_mlo_detachDeviceReqCbFn> cb);
/** /**
* @brief Hooks provided by Salmanoff to senseApi libraries. * @brief Hooks provided by Salmanoff to senseApi libraries.
@@ -88,9 +87,9 @@ struct SmoCallbacks
* @return Shared pointer to the current ComponentThread * @return Shared pointer to the current ComponentThread
* *
* This function provides access to the current ComponentThread instance, * This function provides access to the current ComponentThread instance,
* equivalent to calling ComponentThread::getSelf(). * equivalent to calling sscl::ComponentThread::getSelf().
*/ */
std::shared_ptr<ComponentThread> (*ComponentThread_getSelf)(void); std::shared_ptr<sscl::ComponentThread> (*ComponentThread_getSelf)(void);
/** /**
* @brief Get the OptionParser singleton instance * @brief Get the OptionParser singleton instance
+2 -2
View File
@@ -86,7 +86,7 @@ public:
bool hasBufferWithQualeIfaceApi(const std::string& qualeIfaceApi) const; bool hasBufferWithQualeIfaceApi(const std::string& qualeIfaceApi) const;
protected: protected:
SpinLock frameAssemblyRateLimiter; sscl::SpinLock frameAssemblyRateLimiter;
// Virtual functions for derived classes to override // Virtual functions for derived classes to override
virtual int getStopDelayMs() const virtual int getStopDelayMs() const
@@ -106,7 +106,7 @@ public:
private: private:
boost::asio::io_service& ioService; boost::asio::io_service& ioService;
protected: protected:
SpinLock shouldContinueLock; sscl::SpinLock shouldContinueLock;
bool shouldContinue; bool shouldContinue;
private: private:
boost::asio::deadline_timer timer; boost::asio::deadline_timer timer;
@@ -5,7 +5,7 @@
#include <atomic> #include <atomic>
#include <boost/asio/io_service.hpp> #include <boost/asio/io_service.hpp>
namespace smo { namespace sscl {
class AsynchronousBridge class AsynchronousBridge
{ {
@@ -53,6 +53,6 @@ private:
boost::asio::io_service &io_service; boost::asio::io_service &io_service;
}; };
} // namespace smo } // namespace sscl
#endif // ASYNCHRONOUS_BRIDGE_H #endif // ASYNCHRONOUS_BRIDGE_H
@@ -10,7 +10,7 @@
#include <spinscale/asynchronousContinuationChainLink.h> #include <spinscale/asynchronousContinuationChainLink.h>
namespace smo { namespace sscl {
/** /**
* AsynchronousContinuation - Template base class for async sequence management * AsynchronousContinuation - Template base class for async sequence management
@@ -153,6 +153,6 @@ public:
std::shared_ptr<ComponentThread> caller; std::shared_ptr<ComponentThread> caller;
}; };
} // namespace smo } // namespace sscl
#endif // ASYNCHRONOUS_CONTINUATION_H #endif // ASYNCHRONOUS_CONTINUATION_H
@@ -3,7 +3,7 @@
#include <memory> #include <memory>
namespace smo { namespace sscl {
/** /**
* @brief Base class for all asynchronous continuation chain links * @brief Base class for all asynchronous continuation chain links
@@ -27,6 +27,6 @@ public:
getCallersContinuationShPtr() const = 0; getCallersContinuationShPtr() const = 0;
}; };
} // namespace smo } // namespace sscl
#endif // ASYNCHRONOUS_CONTINUATION_CHAIN_LINK_H #endif // ASYNCHRONOUS_CONTINUATION_CHAIN_LINK_H
@@ -3,7 +3,7 @@
#include <atomic> #include <atomic>
namespace smo { namespace sscl {
class AsynchronousLoop class AsynchronousLoop
{ {
@@ -64,6 +64,6 @@ public:
std::atomic<unsigned int> nSucceeded, nFailed; std::atomic<unsigned int> nSucceeded, nFailed;
}; };
} // namespace smo } // namespace sscl
#endif // ASYNCHRONOUS_LOOP_H #endif // ASYNCHRONOUS_LOOP_H
@@ -13,7 +13,7 @@
// The code will check for OPTS_H define to see if opts.h has been included // The code will check for OPTS_H define to see if opts.h has been included
class OptionParser; class OptionParser;
namespace smo { namespace sscl {
/** /**
* @brief CallableTracer - Wraps callables with metadata for debugging * @brief CallableTracer - Wraps callables with metadata for debugging
@@ -85,7 +85,7 @@ private:
std::function<void()> callable; std::function<void()> callable;
}; };
} // namespace smo } // namespace sscl
/** /**
* @brief STC - SMO Traceable Callable macro * @brief STC - SMO Traceable Callable macro
+2 -2
View File
@@ -3,7 +3,7 @@
#include <memory> #include <memory>
namespace smo { namespace sscl {
// Forward declaration // Forward declaration
class AsynchronousContinuationChainLink; class AsynchronousContinuationChainLink;
@@ -26,6 +26,6 @@ public:
CbFnT callbackFn; CbFnT callbackFn;
}; };
} // namespace smo } // namespace sscl
#endif // SPINSCALE_CALLBACK_H #endif // SPINSCALE_CALLBACK_H
+2 -2
View File
@@ -7,7 +7,7 @@
#include <spinscale/callback.h> #include <spinscale/callback.h>
#include <spinscale/puppetApplication.h> #include <spinscale/puppetApplication.h>
namespace smo { namespace sscl {
class ComponentThread; class ComponentThread;
@@ -36,6 +36,6 @@ public:
PuppetApplication &parent; PuppetApplication &parent;
}; };
} // namespace smo } // namespace sscl
#endif // COMPONENT_H #endif // COMPONENT_H
@@ -17,7 +17,7 @@
#include <cstdint> #include <cstdint>
#include <string> #include <string>
namespace smo { namespace sscl {
class MarionetteThread; class MarionetteThread;
class PuppetThread; class PuppetThread;
@@ -148,17 +148,19 @@ public:
class ThreadLifetimeMgmtOp; class ThreadLifetimeMgmtOp;
}; };
namespace mrntt { } // namespace sscl
extern std::shared_ptr<MarionetteThread> thread;
} // namespace mrntt
namespace smo {
namespace mrntt {
extern std::shared_ptr<sscl::MarionetteThread> thread;
} // namespace mrntt
} // namespace smo } // namespace smo
// Forward declaration for spinscale namespace functions and variables // Forward declaration for sscl namespace functions and variables
// Must be after smo namespace so ThreadId is defined // Must be after sscl namespace so ThreadId is defined
namespace spinscale { namespace sscl {
extern smo::ThreadId marionetteThreadId; extern sscl::ThreadId marionetteThreadId;
void setMarionetteThreadId(smo::ThreadId id); void setMarionetteThreadId(sscl::ThreadId id);
} }
#endif // COMPONENT_THREAD_H #endif // COMPONENT_THREAD_H
@@ -6,7 +6,7 @@
#include <vector> #include <vector>
#include <memory> #include <memory>
namespace smo { namespace sscl {
// Forward declarations // Forward declarations
class AsynchronousContinuationChainLink; class AsynchronousContinuationChainLink;
@@ -80,6 +80,6 @@ private:
AdjacencyList adjacencyList; AdjacencyList adjacencyList;
}; };
} // namespace smo } // namespace sscl
#endif // DEPENDENCY_GRAPH_H #endif // DEPENDENCY_GRAPH_H
+2 -2
View File
@@ -9,7 +9,7 @@
#include <spinscale/qutex.h> #include <spinscale/qutex.h>
#include <spinscale/lockerAndInvokerBase.h> #include <spinscale/lockerAndInvokerBase.h>
namespace smo { namespace sscl {
// Forward declarations // Forward declarations
template <class OriginalCbFnT> template <class OriginalCbFnT>
@@ -255,6 +255,6 @@ private:
bool allLocksAcquired, registeredInQutexQueues; bool allLocksAcquired, registeredInQutexQueues;
}; };
} // namespace smo } // namespace sscl
#endif // LOCK_SET_H #endif // LOCK_SET_H
@@ -4,7 +4,7 @@
#include <list> #include <list>
#include <memory> #include <memory>
namespace smo { namespace sscl {
// Forward declaration // Forward declaration
class Qutex; class Qutex;
@@ -82,6 +82,6 @@ protected:
const void* serializedContinuationVaddr; const void* serializedContinuationVaddr;
}; };
} // namespace smo } // namespace sscl
#endif // LOCKER_AND_INVOKER_BASE_H #endif // LOCKER_AND_INVOKER_BASE_H
@@ -8,7 +8,7 @@
#include <spinscale/callback.h> #include <spinscale/callback.h>
#include <spinscale/componentThread.h> #include <spinscale/componentThread.h>
namespace smo { namespace sscl {
class PuppetApplication class PuppetApplication
: public std::enable_shared_from_this<PuppetApplication> : public std::enable_shared_from_this<PuppetApplication>
@@ -63,6 +63,6 @@ private:
class PuppetThreadLifetimeMgmtOp; class PuppetThreadLifetimeMgmtOp;
}; };
} // namespace smo } // namespace sscl
#endif // PUPPET_APPLICATION_H #endif // PUPPET_APPLICATION_H
+2 -2
View File
@@ -8,7 +8,7 @@
#include <spinscale/spinLock.h> #include <spinscale/spinLock.h>
#include <spinscale/lockerAndInvokerBase.h> #include <spinscale/lockerAndInvokerBase.h>
namespace smo { namespace sscl {
/** /**
* @brief Qutex - Queue-based mutex for asynchronous lock management * @brief Qutex - Queue-based mutex for asynchronous lock management
@@ -102,6 +102,6 @@ public:
bool isOwned; bool isOwned;
}; };
} // namespace smo } // namespace sscl
#endif // QUTEX_H #endif // QUTEX_H
@@ -8,7 +8,7 @@
#include "spinLock.h" #include "spinLock.h"
namespace smo { namespace sscl {
// Forward declarations // Forward declarations
class Qutex; class Qutex;
@@ -159,6 +159,6 @@ private:
AcquisitionHistoryMap acquisitionHistory; AcquisitionHistoryMap acquisitionHistory;
}; };
} // namespace smo } // namespace sscl
#endif // QUTEX_ACQUISITION_HISTORY_TRACKER_H #endif // QUTEX_ACQUISITION_HISTORY_TRACKER_H
@@ -14,7 +14,7 @@
#include <spinscale/callback.h> #include <spinscale/callback.h>
#include <spinscale/qutexAcquisitionHistoryTracker.h> #include <spinscale/qutexAcquisitionHistoryTracker.h>
namespace smo { namespace sscl {
template <class OriginalCbFnT> template <class OriginalCbFnT>
class SerializedAsynchronousContinuation class SerializedAsynchronousContinuation
@@ -583,6 +583,6 @@ void SerializedAsynchronousContinuation<OriginalCbFnT>
invocationTarget(); invocationTarget();
} }
} // namespace smo } // namespace sscl
#endif // SERIALIZED_ASYNCHRONOUS_CONTINUATION_H #endif // SERIALIZED_ASYNCHRONOUS_CONTINUATION_H
+2 -2
View File
@@ -14,7 +14,7 @@
#include <arm_neon.h> #include <arm_neon.h>
#endif #endif
namespace smo { namespace sscl {
/** /**
* @brief Simple spinlock using std::atomic * @brief Simple spinlock using std::atomic
@@ -116,6 +116,6 @@ private:
std::atomic<bool> locked; std::atomic<bool> locked;
}; };
} // namespace smo } // namespace sscl
#endif // SPIN_LOCK_H #endif // SPIN_LOCK_H
+6 -4
View File
@@ -2,7 +2,7 @@
#include <spinscale/puppetApplication.h> #include <spinscale/puppetApplication.h>
#include <marionette/marionette.h> #include <marionette/marionette.h>
namespace smo { namespace sscl {
Component::Component(const std::shared_ptr<ComponentThread> &thread) Component::Component(const std::shared_ptr<ComponentThread> &thread)
: thread(thread) : thread(thread)
@@ -16,14 +16,16 @@ parent(parent)
{ {
} }
} // namespace sscl
namespace smo {
namespace mrntt { namespace mrntt {
MarionetteComponent::MarionetteComponent( MarionetteComponent::MarionetteComponent(
const std::shared_ptr<ComponentThread> &thread) const std::shared_ptr<sscl::ComponentThread> &thread)
: Component(thread) : sscl::Component(thread)
{ {
} }
} // namespace mrntt } // namespace mrntt
} // namespace smo } // namespace smo
+11 -11
View File
@@ -11,27 +11,27 @@
#include <componentThread.h> #include <componentThread.h>
#include <marionette/marionette.h> #include <marionette/marionette.h>
namespace spinscale { namespace sscl {
// Global variable to store the marionette thread ID // Global variable to store the marionette thread ID
// Default value is 0, but should be set by application code via setMarionetteThreadId() // Default value is 0, but should be set by application code via setMarionetteThreadId()
smo::ThreadId marionetteThreadId = 0; sscl::ThreadId marionetteThreadId = 0;
void setMarionetteThreadId(smo::ThreadId id) void setMarionetteThreadId(sscl::ThreadId id)
{ {
marionetteThreadId = id; marionetteThreadId = id;
} }
} // namespace spinscale } // namespace sscl
namespace smo { namespace sscl {
thread_local std::shared_ptr<ComponentThread> thisComponentThread; thread_local std::shared_ptr<ComponentThread> thisComponentThread;
// Implementation of static method // Implementation of static method
std::shared_ptr<MarionetteThread> ComponentThread::getMrntt() std::shared_ptr<MarionetteThread> ComponentThread::getMrntt()
{ {
return mrntt::thread; return smo::mrntt::thread;
} }
void MarionetteThread::initializeTls(void) void MarionetteThread::initializeTls(void)
@@ -179,13 +179,13 @@ void PuppetThread::joltThreadReq(Callback<threadLifetimeMgmtOpCbFn> callback)
* the operation is posted to this thread's io_service (which is a member * the operation is posted to this thread's io_service (which is a member
* of this object), the object must be alive when the operation executes. * of this object), the object must be alive when the operation executes.
*/ */
if (id == spinscale::marionetteThreadId) if (id == sscl::marionetteThreadId)
{ {
throw std::runtime_error(std::string(__func__) throw std::runtime_error(std::string(__func__)
+ ": invoked on mrntt thread"); + ": invoked on mrntt thread");
} }
std::shared_ptr<MarionetteThread> mrntt = mrntt::thread; std::shared_ptr<MarionetteThread> mrntt = smo::mrntt::thread;
auto request = std::make_shared<ThreadLifetimeMgmtOp>( auto request = std::make_shared<ThreadLifetimeMgmtOp>(
mrntt, *this, callback); mrntt, *this, callback);
@@ -228,7 +228,7 @@ void PuppetThread::exitThreadReq(Callback<threadLifetimeMgmtOpCbFn> callback)
void PuppetThread::pauseThreadReq(Callback<threadLifetimeMgmtOpCbFn> callback) void PuppetThread::pauseThreadReq(Callback<threadLifetimeMgmtOpCbFn> callback)
{ {
if (id == spinscale::marionetteThreadId) if (id == sscl::marionetteThreadId)
{ {
throw std::runtime_error(std::string(__func__) throw std::runtime_error(std::string(__func__)
+ ": invoked on mrntt thread"); + ": invoked on mrntt thread");
@@ -246,7 +246,7 @@ void PuppetThread::pauseThreadReq(Callback<threadLifetimeMgmtOpCbFn> callback)
void PuppetThread::resumeThreadReq(Callback<threadLifetimeMgmtOpCbFn> callback) void PuppetThread::resumeThreadReq(Callback<threadLifetimeMgmtOpCbFn> callback)
{ {
if (id == spinscale::marionetteThreadId) if (id == sscl::marionetteThreadId)
{ {
throw std::runtime_error(std::string(__func__) throw std::runtime_error(std::string(__func__)
+ ": invoked on mrntt thread"); + ": invoked on mrntt thread");
@@ -310,4 +310,4 @@ void PuppetThread::pinToCpu(int cpuId)
pinnedCpuId = cpuId; pinnedCpuId = cpuId;
} }
} // namespace smo } // namespace sscl
+2 -2
View File
@@ -1,5 +1,5 @@
#include <spinscale/lockerAndInvokerBase.h> #include <spinscale/lockerAndInvokerBase.h>
namespace smo { namespace sscl {
} // namespace smo } // namespace sscl
+2 -2
View File
@@ -5,7 +5,7 @@
#include <spinscale/puppetApplication.h> #include <spinscale/puppetApplication.h>
#include <spinscale/componentThread.h> #include <spinscale/componentThread.h>
namespace smo { namespace sscl {
PuppetApplication::PuppetApplication( PuppetApplication::PuppetApplication(
const std::vector<std::shared_ptr<PuppetThread>> &threads) const std::vector<std::shared_ptr<PuppetThread>> &threads)
@@ -218,4 +218,4 @@ void PuppetApplication::distributeAndPinThreadsAcrossCpus()
<< "across " << cpuCount << " CPUs\n"; << "across " << cpuCount << " CPUs\n";
} }
} // namespace smo } // namespace sscl
+2 -2
View File
@@ -1,7 +1,7 @@
#include <spinscale/qutex.h> #include <spinscale/qutex.h>
#include <spinscale/lockerAndInvokerBase.h> #include <spinscale/lockerAndInvokerBase.h>
namespace smo { namespace sscl {
bool Qutex::tryAcquire( bool Qutex::tryAcquire(
const LockerAndInvokerBase &tryingLockvoker, int nRequiredLocks const LockerAndInvokerBase &tryingLockvoker, int nRequiredLocks
@@ -377,4 +377,4 @@ void Qutex::release()
front.awaken(); front.awaken();
} }
} // namespace smo } // namespace sscl
@@ -8,7 +8,7 @@
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>
namespace smo { namespace sscl {
void DependencyGraph::addNode(const Node& node) void DependencyGraph::addNode(const Node& node)
{ {
@@ -390,4 +390,4 @@ bool QutexAcquisitionHistoryTracker
return true; return true;
} }
} // namespace smo } // namespace sscl
+1 -1
View File
@@ -7,7 +7,7 @@
int main(int argc, char *argv[], char *envp[]) int main(int argc, char *argv[], char *envp[])
{ {
// Set the marionette thread ID before using any ComponentThread functionality // Set the marionette thread ID before using any ComponentThread functionality
spinscale::setMarionetteThreadId(smo::SmoThreadId::MRNTT); sscl::setMarionetteThreadId(smo::SmoThreadId::MRNTT);
pthread_setname_np(pthread_self(), "smo:CRT:main"); pthread_setname_np(pthread_self(), "smo:CRT:main");
/* We don't do anything inside of main() /* We don't do anything inside of main()
* Main merely waits for the marionette thread to exit. * Main merely waits for the marionette thread to exit.
+16 -16
View File
@@ -14,32 +14,32 @@
namespace smo { namespace smo {
namespace body { namespace body {
Body::Body(Mind &parent, const std::shared_ptr<ComponentThread> &thread) Body::Body(Mind &parent, const std::shared_ptr<sscl::ComponentThread> &thread)
: PuppetComponent(parent, thread) : sscl::PuppetComponent(static_cast<sscl::PuppetApplication&>(parent), thread)
{ {
} }
class Body::InitializeReq class Body::InitializeReq
: public PostedAsynchronousContinuation<bodyLifetimeMgmtOpCbFn> : public sscl::PostedAsynchronousContinuation<bodyLifetimeMgmtOpCbFn>
{ {
public: public:
InitializeReq( InitializeReq(
PuppetApplication &parent, sscl::PuppetApplication &parent,
const std::shared_ptr<ComponentThread> &caller, const std::shared_ptr<sscl::ComponentThread> &caller,
Callback<bodyLifetimeMgmtOpCbFn> callback) sscl::Callback<bodyLifetimeMgmtOpCbFn> callback)
: PostedAsynchronousContinuation<bodyLifetimeMgmtOpCbFn>(caller, callback), : sscl::PostedAsynchronousContinuation<bodyLifetimeMgmtOpCbFn>(caller, callback),
parent(parent) parent(parent)
{} {}
private: private:
PuppetApplication &parent; sscl::PuppetApplication &parent;
public: public:
void initializeReq1_posted( void initializeReq1_posted(
[[maybe_unused]] std::shared_ptr<InitializeReq> context [[maybe_unused]] std::shared_ptr<InitializeReq> context
) )
{ {
auto self = ComponentThread::getSelf(); auto self = sscl::ComponentThread::getSelf();
if (self->id != SmoThreadId::BODY) if (self->id != SmoThreadId::BODY)
{ {
throw std::runtime_error(std::string(__func__) throw std::runtime_error(std::string(__func__)
@@ -94,7 +94,7 @@ public:
void initializeReq2( void initializeReq2(
[[maybe_unused]] std::shared_ptr<InitializeReq> context, [[maybe_unused]] std::shared_ptr<InitializeReq> context,
smo::AsynchronousLoop &results sscl::AsynchronousLoop &results
) )
{ {
std::cout << "Mrntt: attached " std::cout << "Mrntt: attached "
@@ -116,7 +116,7 @@ public:
[[maybe_unused]] std::shared_ptr<FinalizeReq> context [[maybe_unused]] std::shared_ptr<FinalizeReq> context
) )
{ {
auto self = ComponentThread::getSelf(); auto self = sscl::ComponentThread::getSelf();
if (self->id != SmoThreadId::BODY) if (self->id != SmoThreadId::BODY)
{ {
throw std::runtime_error(std::string(__func__) throw std::runtime_error(std::string(__func__)
@@ -133,7 +133,7 @@ public:
void finalizeReq2( void finalizeReq2(
[[maybe_unused]] std::shared_ptr<FinalizeReq> context, [[maybe_unused]] std::shared_ptr<FinalizeReq> context,
smo::AsynchronousLoop &results sscl::AsynchronousLoop &results
) )
{ {
std::cout << "Mrntt: Successfully detached " std::cout << "Mrntt: Successfully detached "
@@ -149,9 +149,9 @@ public:
} }
}; };
void Body::initializeReq(Callback<bodyLifetimeMgmtOpCbFn> callback) void Body::initializeReq(sscl::Callback<bodyLifetimeMgmtOpCbFn> callback)
{ {
auto mrntt = ComponentThread::getSelf(); auto mrntt = sscl::ComponentThread::getSelf();
if (mrntt->id != SmoThreadId::MRNTT) if (mrntt->id != SmoThreadId::MRNTT)
{ {
@@ -168,9 +168,9 @@ void Body::initializeReq(Callback<bodyLifetimeMgmtOpCbFn> callback)
request.get(), request))); request.get(), request)));
} }
void Body::finalizeReq(Callback<bodyLifetimeMgmtOpCbFn> callback) void Body::finalizeReq(sscl::Callback<bodyLifetimeMgmtOpCbFn> callback)
{ {
auto mrntt = ComponentThread::getSelf(); auto mrntt = sscl::ComponentThread::getSelf();
if (mrntt->id != SmoThreadId::MRNTT) if (mrntt->id != SmoThreadId::MRNTT)
{ {
+7 -7
View File
@@ -4,20 +4,20 @@
#include <pthread.h> #include <pthread.h>
#include <componentThread.h> #include <componentThread.h>
namespace smo { namespace sscl {
std::string ComponentThread::getThreadName(ThreadId id) std::string ComponentThread::getThreadName(sscl::ThreadId id)
{ {
// Cast ThreadId to SmoThreadId for validation and lookup // Cast ThreadId to SmoThreadId for validation and lookup
SmoThreadId smoId = static_cast<SmoThreadId>(id); smo::SmoThreadId smoId = static_cast<smo::SmoThreadId>(id);
if (static_cast<int>(smoId) >= static_cast<int>(SmoThreadId::N_ITEMS)) if (static_cast<int>(smoId) >= static_cast<int>(smo::SmoThreadId::N_ITEMS))
{ {
throw std::runtime_error(std::string(__func__) throw std::runtime_error(std::string(__func__)
+ ": Invalid thread ID"); + ": Invalid thread ID");
} }
// Use function-local static to ensure proper initialization order // Use function-local static to ensure proper initialization order
static const std::string threadNames[static_cast<int>(SmoThreadId::N_ITEMS)] static const std::string threadNames[static_cast<int>(smo::SmoThreadId::N_ITEMS)]
= { = {
"mrntt", "mrntt",
"director", "director",
@@ -30,7 +30,7 @@ std::string ComponentThread::getThreadName(ThreadId id)
return threadNames[static_cast<int>(smoId)]; return threadNames[static_cast<int>(smoId)];
} }
void PuppetThread::main(PuppetThread& self) void sscl::PuppetThread::main(sscl::PuppetThread& self)
{ {
std::string threadName = "smo:" + self.name; std::string threadName = "smo:" + self.name;
pthread_setname_np(pthread_self(), threadName.c_str()); pthread_setname_np(pthread_self(), threadName.c_str());
@@ -87,4 +87,4 @@ void PuppetThread::main(PuppetThread& self)
std::cout << self.name << ":" << __func__ << ": Exited event loop" << "\n"; std::cout << self.name << ":" << __func__ << ": Exited event loop" << "\n";
} }
} // namespace smo } // namespace sscl
+54 -54
View File
@@ -45,15 +45,15 @@ const std::string DeviceManager::stringifyDeviceSpecs(void)
} }
class DeviceManager::NewDeviceAttachmentSpecInd class DeviceManager::NewDeviceAttachmentSpecInd
: public SerializedAsynchronousContinuation<newDeviceAttachmentSpecIndCbFn> : public sscl::SerializedAsynchronousContinuation<newDeviceAttachmentSpecIndCbFn>
{ {
public: public:
NewDeviceAttachmentSpecInd( NewDeviceAttachmentSpecInd(
const DeviceAttachmentSpec &spec, const DeviceAttachmentSpec &spec,
const std::shared_ptr<ComponentThread> &caller, const std::shared_ptr<sscl::ComponentThread> &caller,
Callback<newDeviceAttachmentSpecIndCbFn> cb, sscl::Callback<newDeviceAttachmentSpecIndCbFn> cb,
std::vector<std::reference_wrapper<Qutex>> requiredLocks) std::vector<std::reference_wrapper<sscl::Qutex>> requiredLocks)
: SerializedAsynchronousContinuation<newDeviceAttachmentSpecIndCbFn>( : sscl::SerializedAsynchronousContinuation<newDeviceAttachmentSpecIndCbFn>(
caller, cb, requiredLocks), caller, cb, requiredLocks),
spec(spec) spec(spec)
{} {}
@@ -171,15 +171,15 @@ public:
}; };
class DeviceManager::RemoveDeviceAttachmentSpecReq class DeviceManager::RemoveDeviceAttachmentSpecReq
: public SerializedAsynchronousContinuation<removeDeviceAttachmentSpecReqCbFn> : public sscl::SerializedAsynchronousContinuation<removeDeviceAttachmentSpecReqCbFn>
{ {
public: public:
RemoveDeviceAttachmentSpecReq( RemoveDeviceAttachmentSpecReq(
const DeviceAttachmentSpec &spec, const DeviceAttachmentSpec &spec,
const std::shared_ptr<ComponentThread> &caller, const std::shared_ptr<sscl::ComponentThread> &caller,
Callback<removeDeviceAttachmentSpecReqCbFn> cb, sscl::Callback<removeDeviceAttachmentSpecReqCbFn> cb,
std::vector<std::reference_wrapper<Qutex>> requiredLocks) std::vector<std::reference_wrapper<sscl::Qutex>> requiredLocks)
: SerializedAsynchronousContinuation<removeDeviceAttachmentSpecReqCbFn>( : sscl::SerializedAsynchronousContinuation<removeDeviceAttachmentSpecReqCbFn>(
caller, cb, requiredLocks), caller, cb, requiredLocks),
spec(spec) spec(spec)
{} {}
@@ -293,13 +293,13 @@ public:
void DeviceManager::newDeviceAttachmentSpecInd( void DeviceManager::newDeviceAttachmentSpecInd(
const DeviceAttachmentSpec &spec, const DeviceAttachmentSpec &spec,
Callback<newDeviceAttachmentSpecIndCbFn> callback) sscl::Callback<newDeviceAttachmentSpecIndCbFn> callback)
{ {
const auto& caller = ComponentThread::getSelf(); const auto& caller = sscl::ComponentThread::getSelf();
auto request = std::make_shared<NewDeviceAttachmentSpecInd>( auto request = std::make_shared<NewDeviceAttachmentSpecInd>(
spec, caller, callback, spec, caller, callback,
LockSet<newDeviceAttachmentSpecIndCbFn>::Set{ sscl::LockSet<newDeviceAttachmentSpecIndCbFn>::Set{
std::ref(DeviceManager::getInstance().qutex) std::ref(DeviceManager::getInstance().qutex)
}); });
@@ -312,13 +312,13 @@ void DeviceManager::newDeviceAttachmentSpecInd(
void DeviceManager::removeDeviceAttachmentSpecReq( void DeviceManager::removeDeviceAttachmentSpecReq(
const DeviceAttachmentSpec &spec, const DeviceAttachmentSpec &spec,
Callback<removeDeviceAttachmentSpecReqCbFn> callback) sscl::Callback<removeDeviceAttachmentSpecReqCbFn> callback)
{ {
const auto& caller = ComponentThread::getSelf(); const auto& caller = sscl::ComponentThread::getSelf();
auto request = std::make_shared<RemoveDeviceAttachmentSpecReq>( auto request = std::make_shared<RemoveDeviceAttachmentSpecReq>(
spec, caller, callback, spec, caller, callback,
LockSet<removeDeviceAttachmentSpecReqCbFn>::Set{ sscl::LockSet<removeDeviceAttachmentSpecReqCbFn>::Set{
std::ref(DeviceManager::getInstance().qutex) std::ref(DeviceManager::getInstance().qutex)
}); });
@@ -331,17 +331,17 @@ void DeviceManager::removeDeviceAttachmentSpecReq(
} }
class DeviceManager::AttachStimBuffDeviceReq class DeviceManager::AttachStimBuffDeviceReq
: public SerializedAsynchronousContinuation< : public sscl::SerializedAsynchronousContinuation<
DeviceManager::attachStimBuffDeviceReqCbFn> DeviceManager::attachStimBuffDeviceReqCbFn>
{ {
public: public:
AttachStimBuffDeviceReq( AttachStimBuffDeviceReq(
const std::shared_ptr<DeviceAttachmentSpec>& spec, const std::shared_ptr<DeviceAttachmentSpec>& spec,
const std::shared_ptr<ComponentThread> &caller, const std::shared_ptr<sscl::ComponentThread> &caller,
Callback<DeviceManager::attachStimBuffDeviceReqCbFn> cb, sscl::Callback<DeviceManager::attachStimBuffDeviceReqCbFn> cb,
std::shared_ptr<stim_buff::StimBuffApiLib> &stimBuffApiLib, std::shared_ptr<stim_buff::StimBuffApiLib> &stimBuffApiLib,
std::vector<std::reference_wrapper<Qutex>> requiredLocks) std::vector<std::reference_wrapper<sscl::Qutex>> requiredLocks)
: SerializedAsynchronousContinuation<attachStimBuffDeviceReqCbFn>( : sscl::SerializedAsynchronousContinuation<attachStimBuffDeviceReqCbFn>(
caller, cb, requiredLocks), caller, cb, requiredLocks),
spec(spec), stimBuffApiLib(stimBuffApiLib) spec(spec), stimBuffApiLib(stimBuffApiLib)
{} {}
@@ -386,7 +386,7 @@ public:
* Introspectors are attached to the body thread; extrospectors are * Introspectors are attached to the body thread; extrospectors are
* attached to the world thread. * attached to the world thread.
*/ */
std::shared_ptr<ComponentThread> threadForAttachment; std::shared_ptr<sscl::ComponentThread> threadForAttachment;
if (spec->sensorType == 'e') if (spec->sensorType == 'e')
{ {
threadForAttachment = mind::globalMind->world.thread; threadForAttachment = mind::globalMind->world.thread;
@@ -473,10 +473,10 @@ public:
void DeviceManager::attachStimBuffDeviceReq( void DeviceManager::attachStimBuffDeviceReq(
const std::shared_ptr<DeviceAttachmentSpec>& spec, const std::shared_ptr<DeviceAttachmentSpec>& spec,
Callback<attachStimBuffDeviceReqCbFn> cb sscl::Callback<attachStimBuffDeviceReqCbFn> cb
) )
{ {
const auto& caller = ComponentThread::getSelf(); const auto& caller = sscl::ComponentThread::getSelf();
// Get the stim buff API lib's qutex // Get the stim buff API lib's qutex
auto libOpt = stim_buff::StimBuffApiManager::getInstance() auto libOpt = stim_buff::StimBuffApiManager::getInstance()
@@ -494,7 +494,7 @@ void DeviceManager::attachStimBuffDeviceReq(
auto request = std::make_shared<AttachStimBuffDeviceReq>( auto request = std::make_shared<AttachStimBuffDeviceReq>(
spec, caller, cb, libOpt.value(), spec, caller, cb, libOpt.value(),
LockSet<attachStimBuffDeviceReqCbFn>::Set{ sscl::LockSet<attachStimBuffDeviceReqCbFn>::Set{
std::ref(stim_buff::StimBuffApiManager::getInstance().qutex), std::ref(stim_buff::StimBuffApiManager::getInstance().qutex),
std::ref(lib.qutex) std::ref(lib.qutex)
}); });
@@ -508,10 +508,10 @@ void DeviceManager::attachStimBuffDeviceReq(
void DeviceManager::detachStimBuffDeviceReq( void DeviceManager::detachStimBuffDeviceReq(
const std::shared_ptr<DeviceAttachmentSpec>& spec, const std::shared_ptr<DeviceAttachmentSpec>& spec,
Callback<detachStimBuffDeviceReqCbFn> cb sscl::Callback<detachStimBuffDeviceReqCbFn> cb
) )
{ {
const auto& caller = ComponentThread::getSelf(); const auto& caller = sscl::ComponentThread::getSelf();
// Get the stim buff API lib's qutex // Get the stim buff API lib's qutex
auto libOpt = stim_buff::StimBuffApiManager::getInstance() auto libOpt = stim_buff::StimBuffApiManager::getInstance()
@@ -529,7 +529,7 @@ void DeviceManager::detachStimBuffDeviceReq(
auto request = std::make_shared<DetachStimBuffDeviceReq>( auto request = std::make_shared<DetachStimBuffDeviceReq>(
spec, caller, cb, libOpt.value(), spec, caller, cb, libOpt.value(),
LockSet<detachStimBuffDeviceReqCbFn>::Set{ sscl::LockSet<detachStimBuffDeviceReqCbFn>::Set{
std::ref(stim_buff::StimBuffApiManager::getInstance().qutex), std::ref(stim_buff::StimBuffApiManager::getInstance().qutex),
std::ref(lib.qutex) std::ref(lib.qutex)
}); });
@@ -542,16 +542,16 @@ void DeviceManager::detachStimBuffDeviceReq(
} }
class DeviceManager::AttachAllUnattachedDevicesFromReq class DeviceManager::AttachAllUnattachedDevicesFromReq
: public PostedAsynchronousContinuation< : public sscl::PostedAsynchronousContinuation<
attachAllUnattachedDevicesFromReqCbFn> attachAllUnattachedDevicesFromReqCbFn>
{ {
public: public:
AttachAllUnattachedDevicesFromReq( AttachAllUnattachedDevicesFromReq(
const unsigned int totalNSpecs, const unsigned int totalNSpecs,
const std::shared_ptr<std::vector<DeviceAttachmentSpec>>& specs, const std::shared_ptr<std::vector<DeviceAttachmentSpec>>& specs,
const std::shared_ptr<ComponentThread>& caller, const std::shared_ptr<sscl::ComponentThread>& caller,
Callback<attachAllUnattachedDevicesFromReqCbFn> cb) sscl::Callback<attachAllUnattachedDevicesFromReqCbFn> cb)
: PostedAsynchronousContinuation<attachAllUnattachedDevicesFromReqCbFn>( : sscl::PostedAsynchronousContinuation<attachAllUnattachedDevicesFromReqCbFn>(
caller, cb), caller, cb),
loop(totalNSpecs), specs(specs) loop(totalNSpecs), specs(specs)
{} {}
@@ -606,23 +606,23 @@ public:
} }
public: public:
AsynchronousLoop loop; sscl::AsynchronousLoop loop;
std::shared_ptr<std::vector<DeviceAttachmentSpec>> specs; std::shared_ptr<std::vector<DeviceAttachmentSpec>> specs;
}; };
void DeviceManager::attachAllUnattachedDevicesFromReq( void DeviceManager::attachAllUnattachedDevicesFromReq(
const std::shared_ptr<std::vector<DeviceAttachmentSpec>> &specs, const std::shared_ptr<std::vector<DeviceAttachmentSpec>> &specs,
Callback<attachAllUnattachedDevicesFromReqCbFn> cb sscl::Callback<attachAllUnattachedDevicesFromReqCbFn> cb
) )
{ {
if (specs->size() == 0) if (specs->size() == 0)
{ {
AsynchronousLoop tmp(0); sscl::AsynchronousLoop tmp(0);
cb.callbackFn(tmp); cb.callbackFn(tmp);
return; return;
} }
const auto& caller = ComponentThread::getSelf(); const auto& caller = sscl::ComponentThread::getSelf();
auto request = std::make_shared<AttachAllUnattachedDevicesFromReq>( auto request = std::make_shared<AttachAllUnattachedDevicesFromReq>(
specs->size(), specs, caller, std::move(cb)); specs->size(), specs, caller, std::move(cb));
@@ -634,7 +634,7 @@ void DeviceManager::attachAllUnattachedDevicesFromReq(
} }
void DeviceManager::attachAllUnattachedDevicesFromCmdlineReq( void DeviceManager::attachAllUnattachedDevicesFromCmdlineReq(
Callback<attachAllUnattachedDevicesFromReqCbFn> cb sscl::Callback<attachAllUnattachedDevicesFromReqCbFn> cb
) )
{ {
auto specs = std::make_shared<std::vector<DeviceAttachmentSpec>>( auto specs = std::make_shared<std::vector<DeviceAttachmentSpec>>(
@@ -643,15 +643,15 @@ void DeviceManager::attachAllUnattachedDevicesFromCmdlineReq(
} }
class DeviceManager::AttachAllUnattachedDevicesFromKnownListReq class DeviceManager::AttachAllUnattachedDevicesFromKnownListReq
: public SerializedAsynchronousContinuation< : public sscl::SerializedAsynchronousContinuation<
attachAllUnattachedDevicesFromReqCbFn> attachAllUnattachedDevicesFromReqCbFn>
{ {
public: public:
AttachAllUnattachedDevicesFromKnownListReq( AttachAllUnattachedDevicesFromKnownListReq(
const std::shared_ptr<ComponentThread> &caller, const std::shared_ptr<sscl::ComponentThread> &caller,
Callback<attachAllUnattachedDevicesFromReqCbFn> cb, sscl::Callback<attachAllUnattachedDevicesFromReqCbFn> cb,
std::vector<std::reference_wrapper<Qutex>> requiredLocks) std::vector<std::reference_wrapper<sscl::Qutex>> requiredLocks)
: SerializedAsynchronousContinuation< : sscl::SerializedAsynchronousContinuation<
attachAllUnattachedDevicesFromReqCbFn>( attachAllUnattachedDevicesFromReqCbFn>(
caller, cb, requiredLocks) caller, cb, requiredLocks)
{} {}
@@ -703,7 +703,7 @@ public:
void attachAllUnattachedDevicesFromKnownListReq2( void attachAllUnattachedDevicesFromKnownListReq2(
[[maybe_unused]] [[maybe_unused]]
std::shared_ptr<AttachAllUnattachedDevicesFromKnownListReq> context, std::shared_ptr<AttachAllUnattachedDevicesFromKnownListReq> context,
AsynchronousLoop loop sscl::AsynchronousLoop loop
) )
{ {
callOriginalCb(loop); callOriginalCb(loop);
@@ -711,14 +711,14 @@ public:
}; };
void DeviceManager::attachAllUnattachedDevicesFromKnownListReq( void DeviceManager::attachAllUnattachedDevicesFromKnownListReq(
Callback<attachAllUnattachedDevicesFromReqCbFn> cb sscl::Callback<attachAllUnattachedDevicesFromReqCbFn> cb
) )
{ {
const auto& caller = ComponentThread::getSelf(); const auto& caller = sscl::ComponentThread::getSelf();
auto request = std::make_shared<AttachAllUnattachedDevicesFromKnownListReq>( auto request = std::make_shared<AttachAllUnattachedDevicesFromKnownListReq>(
caller, cb, caller, cb,
LockSet<attachAllUnattachedDevicesFromReqCbFn>::Set{ sscl::LockSet<attachAllUnattachedDevicesFromReqCbFn>::Set{
std::ref(DeviceManager::getInstance().qutex) std::ref(DeviceManager::getInstance().qutex)
}); });
@@ -731,15 +731,15 @@ void DeviceManager::attachAllUnattachedDevicesFromKnownListReq(
} }
class DeviceManager::DetachAllAttachedDeviceRoles class DeviceManager::DetachAllAttachedDeviceRoles
: public PostedAsynchronousContinuation< : public sscl::PostedAsynchronousContinuation<
detachAllAttachedDeviceRolesCbFn> detachAllAttachedDeviceRolesCbFn>
{ {
public: public:
DetachAllAttachedDeviceRoles( DetachAllAttachedDeviceRoles(
const unsigned int totalNSpecs, const unsigned int totalNSpecs,
const std::shared_ptr<ComponentThread>& caller, const std::shared_ptr<sscl::ComponentThread>& caller,
Callback<detachAllAttachedDeviceRolesCbFn> cb) sscl::Callback<detachAllAttachedDeviceRolesCbFn> cb)
: PostedAsynchronousContinuation<detachAllAttachedDeviceRolesCbFn>( : sscl::PostedAsynchronousContinuation<detachAllAttachedDeviceRolesCbFn>(
caller, cb), caller, cb),
loop(totalNSpecs) loop(totalNSpecs)
{} {}
@@ -788,21 +788,21 @@ public:
} }
public: public:
AsynchronousLoop loop; sscl::AsynchronousLoop loop;
}; };
void DeviceManager::detachAllAttachedDeviceRoles( void DeviceManager::detachAllAttachedDeviceRoles(
Callback<detachAllAttachedDeviceRolesCbFn> cb sscl::Callback<detachAllAttachedDeviceRolesCbFn> cb
) )
{ {
if (DeviceManager::getInstance().attachedDeviceRoles.size() == 0) if (DeviceManager::getInstance().attachedDeviceRoles.size() == 0)
{ {
AsynchronousLoop tmp(0); sscl::AsynchronousLoop tmp(0);
cb.callbackFn(tmp); cb.callbackFn(tmp);
return; return;
} }
const auto& caller = ComponentThread::getSelf(); const auto& caller = sscl::ComponentThread::getSelf();
auto request = std::make_shared<DetachAllAttachedDeviceRoles>( auto request = std::make_shared<DetachAllAttachedDeviceRoles>(
DeviceManager::getInstance().attachedDeviceRoles.size(), DeviceManager::getInstance().attachedDeviceRoles.size(),
caller, std::move(cb)); caller, std::move(cb));
+4 -4
View File
@@ -9,7 +9,7 @@
namespace smo { namespace smo {
namespace device { namespace device {
static void reattachmentCb(AsynchronousLoop& results) static void reattachmentCb(sscl::AsynchronousLoop& results)
{ {
if (results.nTotal == 0) { return; } if (results.nTotal == 0) { return; }
@@ -19,7 +19,7 @@ static void reattachmentCb(AsynchronousLoop& results)
} }
DeviceReattacher::DeviceReattacher( DeviceReattacher::DeviceReattacher(
DeviceManager& parent, std::shared_ptr<ComponentThread> ioThread) DeviceManager& parent, std::shared_ptr<sscl::ComponentThread> ioThread)
: parent(parent), ioThread(ioThread), shouldContinue(false), : parent(parent), ioThread(ioThread), shouldContinue(false),
timer(ioThread->getIoService()) timer(ioThread->getIoService())
{ {
@@ -34,7 +34,7 @@ void DeviceReattacher::start()
void DeviceReattacher::stop() void DeviceReattacher::stop()
{ {
{ {
SpinLock::Guard lock(shouldContinueLock); sscl::SpinLock::Guard lock(shouldContinueLock);
shouldContinue = false; shouldContinue = false;
} }
@@ -70,7 +70,7 @@ void DeviceReattacher::onTimeout(const boost::system::error_code& error)
return; return;
} }
SpinLock::Guard lock(shouldContinueLock); sscl::SpinLock::Guard lock(shouldContinueLock);
if (!shouldContinue) { if (!shouldContinue) {
return; return;
} }
+2 -2
View File
@@ -6,8 +6,8 @@
namespace smo { namespace smo {
namespace director { namespace director {
Director::Director(Mind &parent, const std::shared_ptr<ComponentThread> &thread) Director::Director(Mind &parent, const std::shared_ptr<sscl::ComponentThread> &thread)
: PuppetComponent(static_cast<PuppetApplication&>(parent), thread) : sscl::PuppetComponent(static_cast<sscl::PuppetApplication&>(parent), thread)
{ {
} }
+4 -5
View File
@@ -9,20 +9,19 @@
namespace smo { namespace smo {
class Mind; class Mind;
class ComponentThread;
namespace body { namespace body {
class Body class Body
: public PuppetComponent : public sscl::PuppetComponent
{ {
public: public:
Body(Mind &parent, const std::shared_ptr<ComponentThread> &thread); Body(Mind &parent, const std::shared_ptr<sscl::ComponentThread> &thread);
~Body() = default; ~Body() = default;
typedef std::function<void(bool)> bodyLifetimeMgmtOpCbFn; typedef std::function<void(bool)> bodyLifetimeMgmtOpCbFn;
void initializeReq(Callback<bodyLifetimeMgmtOpCbFn> callback); void initializeReq(sscl::Callback<bodyLifetimeMgmtOpCbFn> callback);
void finalizeReq(Callback<bodyLifetimeMgmtOpCbFn> callback); void finalizeReq(sscl::Callback<bodyLifetimeMgmtOpCbFn> callback);
private: private:
class InitializeReq; class InitializeReq;
+1 -1
View File
@@ -9,7 +9,7 @@ namespace smo {
// Application-specific thread ID enum // Application-specific thread ID enum
// Using regular enum (not enum class) to allow implicit conversion to ThreadId // Using regular enum (not enum class) to allow implicit conversion to ThreadId
enum SmoThreadId : ThreadId enum SmoThreadId : sscl::ThreadId
{ {
MRNTT = 0, MRNTT = 0,
DIRECTOR, DIRECTOR,
+1 -1
View File
@@ -33,7 +33,7 @@ public:
public: public:
std::string deviceIdentifier; std::string deviceIdentifier;
std::vector<std::shared_ptr<DeviceRole>> deviceRoles; std::vector<std::shared_ptr<DeviceRole>> deviceRoles;
Qutex qutex; sscl::Qutex qutex;
}; };
} // namespace device } // namespace device
+11 -11
View File
@@ -55,10 +55,10 @@ public:
void newDeviceAttachmentSpecInd( void newDeviceAttachmentSpecInd(
const DeviceAttachmentSpec &spec, const DeviceAttachmentSpec &spec,
Callback<newDeviceAttachmentSpecIndCbFn> callback); sscl::Callback<newDeviceAttachmentSpecIndCbFn> callback);
void removeDeviceAttachmentSpecReq( void removeDeviceAttachmentSpecReq(
const DeviceAttachmentSpec &spec, const DeviceAttachmentSpec &spec,
Callback<removeDeviceAttachmentSpecReqCbFn> callback); sscl::Callback<removeDeviceAttachmentSpecReqCbFn> callback);
// Device attachment/detachment methods moved from SenseApiManager // Device attachment/detachment methods moved from SenseApiManager
typedef stim_buff::sal_mlo_attachDeviceReqCbFn attachStimBuffDeviceReqCbFn; typedef stim_buff::sal_mlo_attachDeviceReqCbFn attachStimBuffDeviceReqCbFn;
@@ -66,25 +66,25 @@ public:
void attachStimBuffDeviceReq( void attachStimBuffDeviceReq(
const std::shared_ptr<DeviceAttachmentSpec>& spec, const std::shared_ptr<DeviceAttachmentSpec>& spec,
Callback<attachStimBuffDeviceReqCbFn> cb); sscl::Callback<attachStimBuffDeviceReqCbFn> cb);
void detachStimBuffDeviceReq( void detachStimBuffDeviceReq(
const std::shared_ptr<DeviceAttachmentSpec>& spec, const std::shared_ptr<DeviceAttachmentSpec>& spec,
Callback<detachStimBuffDeviceReqCbFn> cb); sscl::Callback<detachStimBuffDeviceReqCbFn> cb);
typedef std::function<void(AsynchronousLoop &results)> typedef std::function<void(sscl::AsynchronousLoop &results)>
attachAllUnattachedDevicesFromReqCbFn; attachAllUnattachedDevicesFromReqCbFn;
typedef std::function<void(AsynchronousLoop &results)> typedef std::function<void(sscl::AsynchronousLoop &results)>
detachAllAttachedDeviceRolesCbFn; detachAllAttachedDeviceRolesCbFn;
void attachAllUnattachedDevicesFromReq( void attachAllUnattachedDevicesFromReq(
const std::shared_ptr<std::vector<DeviceAttachmentSpec>> &specs, const std::shared_ptr<std::vector<DeviceAttachmentSpec>> &specs,
Callback<attachAllUnattachedDevicesFromReqCbFn> cb); sscl::Callback<attachAllUnattachedDevicesFromReqCbFn> cb);
void attachAllUnattachedDevicesFromKnownListReq( void attachAllUnattachedDevicesFromKnownListReq(
Callback<attachAllUnattachedDevicesFromReqCbFn> cb); sscl::Callback<attachAllUnattachedDevicesFromReqCbFn> cb);
void attachAllUnattachedDevicesFromCmdlineReq( void attachAllUnattachedDevicesFromCmdlineReq(
Callback<attachAllUnattachedDevicesFromReqCbFn> cb); sscl::Callback<attachAllUnattachedDevicesFromReqCbFn> cb);
void detachAllAttachedDeviceRoles( void detachAllAttachedDeviceRoles(
Callback<detachAllAttachedDeviceRolesCbFn> cb); sscl::Callback<detachAllAttachedDeviceRolesCbFn> cb);
private: private:
DeviceManager() DeviceManager()
@@ -95,7 +95,7 @@ private:
DeviceManager& operator=(const DeviceManager&) = delete; DeviceManager& operator=(const DeviceManager&) = delete;
public: public:
Qutex qutex; sscl::Qutex qutex;
std::string allDapSpecs; std::string allDapSpecs;
static std::vector<std::shared_ptr<DeviceAttachmentSpec>> static std::vector<std::shared_ptr<DeviceAttachmentSpec>>
deviceAttachmentSpecs; deviceAttachmentSpecs;
@@ -9,8 +9,6 @@
namespace smo { namespace smo {
class ComponentThread;
namespace device { namespace device {
class DeviceManager; class DeviceManager;
@@ -19,7 +17,7 @@ class DeviceReattacher
{ {
public: public:
DeviceReattacher( DeviceReattacher(
DeviceManager& parent, std::shared_ptr<ComponentThread> ioThread); DeviceManager& parent, std::shared_ptr<sscl::ComponentThread> ioThread);
~DeviceReattacher() = default; ~DeviceReattacher() = default;
// Non-copyable // Non-copyable
@@ -35,8 +33,8 @@ private:
void onTimeout(const boost::system::error_code& error); void onTimeout(const boost::system::error_code& error);
DeviceManager &parent; DeviceManager &parent;
std::shared_ptr<ComponentThread> ioThread; std::shared_ptr<sscl::ComponentThread> ioThread;
SpinLock shouldContinueLock; sscl::SpinLock shouldContinueLock;
bool shouldContinue; bool shouldContinue;
boost::asio::deadline_timer timer; boost::asio::deadline_timer timer;
}; };
+2 -3
View File
@@ -10,15 +10,14 @@
namespace smo { namespace smo {
class Mind; class Mind;
class ComponentThread;
namespace director { namespace director {
class Director class Director
: public PuppetComponent : public sscl::PuppetComponent
{ {
public: public:
Director(Mind &parent, const std::shared_ptr<ComponentThread> &thread); Director(Mind &parent, const std::shared_ptr<sscl::ComponentThread> &thread);
~Director() = default; ~Director() = default;
void negtrinEventInd(void); void negtrinEventInd(void);
+4 -4
View File
@@ -13,16 +13,16 @@ class MarionetteThread;
namespace mrntt { namespace mrntt {
class MarionetteComponent class MarionetteComponent
: public Component : public sscl::Component
{ {
public: public:
MarionetteComponent(const std::shared_ptr<ComponentThread> &thread); MarionetteComponent(const std::shared_ptr<sscl::ComponentThread> &thread);
~MarionetteComponent() = default; ~MarionetteComponent() = default;
public: public:
typedef std::function<void(bool)> mrnttLifetimeMgmtOpCbFn; typedef std::function<void(bool)> mrnttLifetimeMgmtOpCbFn;
void initializeReq(Callback<mrnttLifetimeMgmtOpCbFn> callback); void initializeReq(sscl::Callback<mrnttLifetimeMgmtOpCbFn> callback);
void finalizeReq(Callback<mrnttLifetimeMgmtOpCbFn> callback); void finalizeReq(sscl::Callback<mrnttLifetimeMgmtOpCbFn> callback);
// Intentionally doesn't take a callback. // Intentionally doesn't take a callback.
void exceptionInd(); void exceptionInd();
+6 -6
View File
@@ -18,18 +18,18 @@
namespace smo { namespace smo {
class Mind class Mind
: public PuppetApplication : public sscl::PuppetApplication
{ {
public: public:
Mind(void); Mind(void);
~Mind(void) = default; ~Mind(void) = default;
typedef std::function<void(bool)> mindLifetimeMgmtOpCbFn; typedef std::function<void(bool)> mindLifetimeMgmtOpCbFn;
void initializeReq(Callback<mindLifetimeMgmtOpCbFn> callback); void initializeReq(sscl::Callback<mindLifetimeMgmtOpCbFn> callback);
void finalizeReq(Callback<mindLifetimeMgmtOpCbFn> callback); void finalizeReq(sscl::Callback<mindLifetimeMgmtOpCbFn> callback);
// ComponentThread access methods // ComponentThread access methods
std::shared_ptr<MindThread> getComponentThread(ThreadId id) const; std::shared_ptr<MindThread> getComponentThread(sscl::ThreadId id) const;
std::shared_ptr<MindThread> getComponentThread( std::shared_ptr<MindThread> getComponentThread(
const std::string& name) const; const std::string& name) const;
// Get all this Mind's component threads. // Get all this Mind's component threads.
@@ -38,9 +38,9 @@ public:
public: public:
director::Director director; director::Director director;
simulator::Simulator canvas; simulator::Simulator canvas;
PuppetComponent subconscious; sscl::PuppetComponent subconscious;
body::Body body; body::Body body;
PuppetComponent world; sscl::PuppetComponent world;
private: private:
friend class body::Body; friend class body::Body;
+3 -3
View File
@@ -9,11 +9,11 @@ namespace smo {
class Mind; // Forward declaration class Mind; // Forward declaration
class MindThread class MindThread
: public PuppetThread : public sscl::PuppetThread
{ {
public: public:
MindThread(ThreadId _id, Mind& parent) MindThread(sscl::ThreadId _id, Mind& parent)
: PuppetThread(_id), : sscl::PuppetThread(_id),
parent(parent) parent(parent)
{ {
} }
+2 -3
View File
@@ -9,15 +9,14 @@
namespace smo { namespace smo {
class Mind; class Mind;
class ComponentThread;
namespace simulator { namespace simulator {
class Simulator class Simulator
: public PuppetComponent : public sscl::PuppetComponent
{ {
public: public:
Simulator(Mind &parent, const std::shared_ptr<ComponentThread> &thread); Simulator(Mind &parent, const std::shared_ptr<sscl::ComponentThread> &thread);
~Simulator() = default; ~Simulator() = default;
void initialize(); void initialize();
@@ -51,7 +51,7 @@ public:
public: public:
std::string libraryPath; std::string libraryPath;
Qutex qutex; sscl::Qutex qutex;
std::atomic<bool> isBeingDestroyed; std::atomic<bool> isBeingDestroyed;
std::unique_ptr<void, DlCloser> dlopen_handle; std::unique_ptr<void, DlCloser> dlopen_handle;
/* UNIMPLEMENTED: API-specific cmdline options. These affect this specific /* UNIMPLEMENTED: API-specific cmdline options. These affect this specific
@@ -32,7 +32,7 @@ public:
StimBuffApiLib& loadStimBuffApiLib( StimBuffApiLib& loadStimBuffApiLib(
const std::string& libraryPath, const std::string& libraryPath,
const std::shared_ptr<ComponentThread>& componentThread); const std::shared_ptr<sscl::ComponentThread>& componentThread);
std::optional<std::shared_ptr<StimBuffApiLib>> getStimBuffApiLib( std::optional<std::shared_ptr<StimBuffApiLib>> getStimBuffApiLib(
const std::string& libraryPath); const std::string& libraryPath);
@@ -44,7 +44,7 @@ public:
void finalizeStimBuffApiLib(StimBuffApiLib& lib); void finalizeStimBuffApiLib(StimBuffApiLib& lib);
void loadAllStimBuffApiLibsFromOptions( void loadAllStimBuffApiLibsFromOptions(
const std::shared_ptr<ComponentThread>& componentThread); const std::shared_ptr<sscl::ComponentThread>& componentThread);
void unloadAllStimBuffApiLibs(void); void unloadAllStimBuffApiLibs(void);
void initializeAllStimBuffApiLibs(void); void initializeAllStimBuffApiLibs(void);
@@ -64,7 +64,7 @@ private:
std::vector<std::shared_ptr<StimBuffApiLib>> stimBuffApiLibs; std::vector<std::shared_ptr<StimBuffApiLib>> stimBuffApiLibs;
public: public:
Qutex qutex; sscl::Qutex qutex;
public: public:
static std::optional<std::string> searchForLibInSmoSearchPaths( static std::optional<std::string> searchForLibInSmoSearchPaths(
+16 -16
View File
@@ -13,13 +13,13 @@ namespace smo {
namespace mrntt { namespace mrntt {
class MarionetteComponent::MrnttLifetimeMgmtOp class MarionetteComponent::MrnttLifetimeMgmtOp
: public PostedAsynchronousContinuation<mrnttLifetimeMgmtOpCbFn> : public sscl::PostedAsynchronousContinuation<mrnttLifetimeMgmtOpCbFn>
{ {
public: public:
MrnttLifetimeMgmtOp( MrnttLifetimeMgmtOp(
MarionetteComponent &parent, const std::shared_ptr<ComponentThread> &caller, MarionetteComponent &parent, const std::shared_ptr<sscl::ComponentThread> &caller,
Callback<mrnttLifetimeMgmtOpCbFn> callback) sscl::Callback<mrnttLifetimeMgmtOpCbFn> callback)
: PostedAsynchronousContinuation<mrnttLifetimeMgmtOpCbFn>( : sscl::PostedAsynchronousContinuation<mrnttLifetimeMgmtOpCbFn>(
caller, callback), caller, callback),
parent(parent) parent(parent)
{} {}
@@ -32,7 +32,7 @@ public:
[[maybe_unused]] std::shared_ptr<MrnttLifetimeMgmtOp> context [[maybe_unused]] std::shared_ptr<MrnttLifetimeMgmtOp> context
) )
{ {
auto self = ComponentThread::getSelf(); auto self = sscl::ComponentThread::getSelf();
if (self->id != SmoThreadId::MRNTT) if (self->id != SmoThreadId::MRNTT)
{ {
throw std::runtime_error(std::string(__func__) throw std::runtime_error(std::string(__func__)
@@ -70,7 +70,7 @@ public:
[[maybe_unused]] std::shared_ptr<MrnttLifetimeMgmtOp> context [[maybe_unused]] std::shared_ptr<MrnttLifetimeMgmtOp> context
) )
{ {
auto self = ComponentThread::getSelf(); auto self = sscl::ComponentThread::getSelf();
if (self->id != SmoThreadId::MRNTT) if (self->id != SmoThreadId::MRNTT)
{ {
throw std::runtime_error(std::string(__func__) throw std::runtime_error(std::string(__func__)
@@ -118,12 +118,12 @@ public:
}; };
class MarionetteComponent::TerminationEvent class MarionetteComponent::TerminationEvent
: public PostedAsynchronousContinuation<mrnttLifetimeMgmtOpCbFn> : public sscl::PostedAsynchronousContinuation<mrnttLifetimeMgmtOpCbFn>
{ {
public: public:
TerminationEvent( TerminationEvent(
const std::shared_ptr<ComponentThread> &caller) const std::shared_ptr<sscl::ComponentThread> &caller)
: PostedAsynchronousContinuation<mrnttLifetimeMgmtOpCbFn>( : sscl::PostedAsynchronousContinuation<mrnttLifetimeMgmtOpCbFn>(
caller, {nullptr, nullptr}) caller, {nullptr, nullptr})
{} {}
@@ -132,7 +132,7 @@ public:
[[maybe_unused]] std::shared_ptr<TerminationEvent> context [[maybe_unused]] std::shared_ptr<TerminationEvent> context
) )
{ {
auto self = ComponentThread::getSelf(); auto self = sscl::ComponentThread::getSelf();
if (self->id != SmoThreadId::MRNTT) if (self->id != SmoThreadId::MRNTT)
{ {
throw std::runtime_error(std::string(__func__) throw std::runtime_error(std::string(__func__)
@@ -146,9 +146,9 @@ public:
}; };
void MarionetteComponent::initializeReq( void MarionetteComponent::initializeReq(
Callback<mrnttLifetimeMgmtOpCbFn> callback) sscl::Callback<mrnttLifetimeMgmtOpCbFn> callback)
{ {
auto mrntt = ComponentThread::getSelf(); auto mrntt = sscl::ComponentThread::getSelf();
if (mrntt->id != SmoThreadId::MRNTT) if (mrntt->id != SmoThreadId::MRNTT)
{ {
@@ -166,9 +166,9 @@ void MarionetteComponent::initializeReq(
} }
void MarionetteComponent::finalizeReq( void MarionetteComponent::finalizeReq(
Callback<mrnttLifetimeMgmtOpCbFn> callback) sscl::Callback<mrnttLifetimeMgmtOpCbFn> callback)
{ {
auto mrntt = ComponentThread::getSelf(); auto mrntt = sscl::ComponentThread::getSelf();
if (mrntt->id != SmoThreadId::MRNTT) if (mrntt->id != SmoThreadId::MRNTT)
{ {
@@ -187,8 +187,8 @@ void MarionetteComponent::finalizeReq(
void MarionetteComponent::exceptionInd() void MarionetteComponent::exceptionInd()
{ {
auto faultyThread = ComponentThread::getSelf(); auto faultyThread = sscl::ComponentThread::getSelf();
auto mrntt = ComponentThread::getMrntt(); auto mrntt = sscl::ComponentThread::getMrntt();
auto request = std::make_shared<TerminationEvent>( auto request = std::make_shared<TerminationEvent>(
faultyThread); faultyThread);
+26 -21
View File
@@ -8,8 +8,9 @@
#include <typeinfo> #include <typeinfo>
#include <boost/asio/signal_set.hpp> #include <boost/asio/signal_set.hpp>
#include <spinscale/asynchronousBridge.h> #include <spinscale/asynchronousBridge.h>
#include <mindManager/mindManager.h> #include <spinscale/componentThread.h>
#include <componentThread.h> #include <componentThread.h>
#include <mindManager/mindManager.h>
#include <marionette/marionette.h> #include <marionette/marionette.h>
#include <salmanoff.h> #include <salmanoff.h>
@@ -25,14 +26,14 @@ void CrtCommandLineArgs::set(int argc, char *argv[], char *envp[])
namespace mrntt { namespace mrntt {
std::atomic<int> exitCode; std::atomic<int> exitCode;
// Global marionette thread instance // Global marionette thread instance
std::shared_ptr<MarionetteThread> thread = std::shared_ptr<sscl::MarionetteThread> thread =
std::make_shared<MarionetteThread>(); std::make_shared<sscl::MarionetteThread>();
MarionetteComponent mrntt(thread); MarionetteComponent mrntt(std::static_pointer_cast<sscl::ComponentThread>(thread));
void exitMarionetteLoop() void exitMarionetteLoop()
{ {
mrntt::thread->keepLooping = false; thread->keepLooping = false;
mrntt::thread->getIoService().stop(); thread->getIoService().stop();
std::cout << "Mrntt: Signaled main loop to exit." << "\n"; std::cout << "Mrntt: Signaled main loop to exit." << "\n";
} }
@@ -65,6 +66,10 @@ void marionetteInitializeReqCb(bool success)
} // namespace mrntt } // namespace mrntt
} // namespace smo
namespace sscl {
void MarionetteThread::main(MarionetteThread& self) void MarionetteThread::main(MarionetteThread& self)
{ {
std::string threadName = "smo:" + self.name; std::string threadName = "smo:" + self.name;
@@ -73,7 +78,7 @@ void MarionetteThread::main(MarionetteThread& self)
std::cout << __func__ << ": Waiting for command line JOLT" << std::endl; std::cout << __func__ << ": Waiting for command line JOLT" << std::endl;
self.getIoService().run(); self.getIoService().run();
self.initializeTls(); self.initializeTls();
mrntt::exitCode = EXIT_SUCCESS; smo::mrntt::exitCode = EXIT_SUCCESS;
static boost::asio::signal_set signals(self.getIoService(), SIGINT); static boost::asio::signal_set signals(self.getIoService(), SIGINT);
bool callShutdownSalmanoff = false; bool callShutdownSalmanoff = false;
@@ -95,8 +100,8 @@ void MarionetteThread::main(MarionetteThread& self)
default: default:
break; break;
} }
mrntt::mrntt.finalizeReq({nullptr, std::bind( smo::mrntt::mrntt.finalizeReq({nullptr, std::bind(
&mrntt::marionetteFinalizeReqCb, &smo::mrntt::marionetteFinalizeReqCb,
std::placeholders::_1)}); std::placeholders::_1)});
} }
); );
@@ -107,8 +112,8 @@ void MarionetteThread::main(MarionetteThread& self)
<< std::endl; << std::endl;
options.parseArguments( options.parseArguments(
crtCommandLineArgs.argc, crtCommandLineArgs.argv, smo::crtCommandLineArgs.argc, smo::crtCommandLineArgs.argv,
crtCommandLineArgs.envp); smo::crtCommandLineArgs.envp);
std::cout << __func__ << ": " << options.stringifyOptions() std::cout << __func__ << ": " << options.stringifyOptions()
<< std::endl; << std::endl;
@@ -135,12 +140,12 @@ void MarionetteThread::main(MarionetteThread& self)
* The latter is cleaner and more resource-respecting. The former is * The latter is cleaner and more resource-respecting. The former is
* easier to implement. * easier to implement.
*/ */
initializeSalmanoff(); smo::initializeSalmanoff();
callShutdownSalmanoff = true; callShutdownSalmanoff = true;
// Create new Mind instance just before initializeReq // Create new Mind instance just before initializeReq
mrntt::mrntt.initializeReq({nullptr, std::bind( smo::mrntt::mrntt.initializeReq({nullptr, std::bind(
&mrntt::marionetteInitializeReqCb, std::placeholders::_1)}); &smo::mrntt::marionetteInitializeReqCb, std::placeholders::_1)});
std::cout << __func__ << ": Entering event loop" << "\n"; std::cout << __func__ << ": Entering event loop" << "\n";
@@ -183,8 +188,8 @@ void MarionetteThread::main(MarionetteThread& self)
if (sendExceptionInd) if (sendExceptionInd)
{ {
mrntt::exitCode = EXIT_FAILURE; smo::mrntt::exitCode = EXIT_FAILURE;
mrntt::mrntt.exceptionInd(); smo::mrntt::mrntt.exceptionInd();
} }
} }
@@ -197,7 +202,7 @@ void MarionetteThread::main(MarionetteThread& self)
if (typeid(e) == typeid(OptionsParserError)) if (typeid(e) == typeid(OptionsParserError))
{ {
mrntt::exitCode = EXIT_FAILURE; smo::mrntt::exitCode = EXIT_FAILURE;
out = &std::cerr; out = &std::cerr;
outUsageMsg = std::string(__func__) + ": "; outUsageMsg = std::string(__func__) + ": ";
} }
@@ -208,17 +213,17 @@ void MarionetteThread::main(MarionetteThread& self)
{ {
std::cerr << __func__ << ": Exception occurred: " << e.what() std::cerr << __func__ << ": Exception occurred: " << e.what()
<< std::endl; << std::endl;
mrntt::exitCode = EXIT_FAILURE; smo::mrntt::exitCode = EXIT_FAILURE;
} }
catch (...) catch (...)
{ {
std::cerr << __func__ << ": Unknown exception occurred" << std::endl; std::cerr << __func__ << ": Unknown exception occurred" << std::endl;
mrntt::exitCode = EXIT_FAILURE; smo::mrntt::exitCode = EXIT_FAILURE;
} }
if (callShutdownSalmanoff) { if (callShutdownSalmanoff) {
shutdownSalmanoff(); smo::shutdownSalmanoff();
} }
} }
} // namespace smo } // namespace sscl
+17 -17
View File
@@ -14,8 +14,8 @@
namespace smo { namespace smo {
Mind::Mind(void) Mind::Mind(void)
: PuppetApplication( : sscl::PuppetApplication(
std::vector<std::shared_ptr<PuppetThread>>{ std::vector<std::shared_ptr<sscl::PuppetThread>>{
std::make_shared<MindThread>(SmoThreadId::DIRECTOR, *this), std::make_shared<MindThread>(SmoThreadId::DIRECTOR, *this),
std::make_shared<MindThread>(SmoThreadId::SIMULATOR, *this), std::make_shared<MindThread>(SmoThreadId::SIMULATOR, *this),
std::make_shared<MindThread>(SmoThreadId::SUBCONSCIOUS, *this), std::make_shared<MindThread>(SmoThreadId::SUBCONSCIOUS, *this),
@@ -24,22 +24,22 @@ Mind::Mind(void)
, std::make_shared<MindThread>(SmoThreadId::WORLD, *this) , std::make_shared<MindThread>(SmoThreadId::WORLD, *this)
#endif #endif
}), }),
director(*this, std::static_pointer_cast<MindThread>(componentThreads[0])), director(*this, std::static_pointer_cast<sscl::ComponentThread>(componentThreads[0])),
canvas(*this, std::static_pointer_cast<MindThread>(componentThreads[1])), canvas(*this, std::static_pointer_cast<sscl::ComponentThread>(componentThreads[1])),
subconscious(*this, std::static_pointer_cast<MindThread>(componentThreads[2])), subconscious(*this, std::static_pointer_cast<sscl::ComponentThread>(componentThreads[2])),
body(*this, std::static_pointer_cast<MindThread>(componentThreads[3])), body(*this, std::static_pointer_cast<sscl::ComponentThread>(componentThreads[3])),
world(*this, world(*this,
#ifndef CONFIG_WORLD_USE_BODY_THREAD #ifndef CONFIG_WORLD_USE_BODY_THREAD
std::static_pointer_cast<MindThread>(componentThreads[4]) std::static_pointer_cast<sscl::ComponentThread>(componentThreads[4])
#else #else
std::static_pointer_cast<MindThread>(componentThreads[3]) std::static_pointer_cast<sscl::ComponentThread>(componentThreads[3])
#endif #endif
) )
{ {
} }
std::shared_ptr<MindThread> std::shared_ptr<MindThread>
Mind::getComponentThread(ThreadId id) const Mind::getComponentThread(sscl::ThreadId id) const
{ {
if (id == SmoThreadId::MRNTT) if (id == SmoThreadId::MRNTT)
{ {
@@ -98,13 +98,13 @@ Mind::getMindThreads() const
} }
class Mind::MindLifetimeMgmtOp class Mind::MindLifetimeMgmtOp
: public PostedAsynchronousContinuation<mindLifetimeMgmtOpCbFn> : public sscl::PostedAsynchronousContinuation<mindLifetimeMgmtOpCbFn>
{ {
public: public:
MindLifetimeMgmtOp( MindLifetimeMgmtOp(
Mind &parent, const std::shared_ptr<ComponentThread> &caller, Mind &parent, const std::shared_ptr<sscl::ComponentThread> &caller,
Callback<mindLifetimeMgmtOpCbFn> callback) sscl::Callback<mindLifetimeMgmtOpCbFn> callback)
: PostedAsynchronousContinuation<mindLifetimeMgmtOpCbFn>( : sscl::PostedAsynchronousContinuation<mindLifetimeMgmtOpCbFn>(
caller, callback), caller, callback),
parent(parent) parent(parent)
{} {}
@@ -209,7 +209,7 @@ public:
} }
}; };
void Mind::initializeReq(Callback<mindLifetimeMgmtOpCbFn> callback) void Mind::initializeReq(sscl::Callback<mindLifetimeMgmtOpCbFn> callback)
{ {
/* Distribute threads across available CPUs */ /* Distribute threads across available CPUs */
try try
@@ -223,7 +223,7 @@ void Mind::initializeReq(Callback<mindLifetimeMgmtOpCbFn> callback)
"Error: " << e.what() << "\n"; "Error: " << e.what() << "\n";
} }
const auto& caller = ComponentThread::getSelf(); const auto& caller = sscl::ComponentThread::getSelf();
auto request = std::make_shared<MindLifetimeMgmtOp>( auto request = std::make_shared<MindLifetimeMgmtOp>(
*this, caller, callback); *this, caller, callback);
@@ -233,9 +233,9 @@ void Mind::initializeReq(Callback<mindLifetimeMgmtOpCbFn> callback)
request.get(), request))); request.get(), request)));
} }
void Mind::finalizeReq(Callback<mindLifetimeMgmtOpCbFn> callback) void Mind::finalizeReq(sscl::Callback<mindLifetimeMgmtOpCbFn> callback)
{ {
const auto& caller = ComponentThread::getSelf(); const auto& caller = sscl::ComponentThread::getSelf();
auto request = std::make_shared<MindLifetimeMgmtOp>( auto request = std::make_shared<MindLifetimeMgmtOp>(
*this, caller, callback); *this, caller, callback);
+2 -2
View File
@@ -4,8 +4,8 @@
namespace smo { namespace smo {
namespace simulator { namespace simulator {
Simulator::Simulator(Mind &parent, const std::shared_ptr<ComponentThread> &thread) Simulator::Simulator(Mind &parent, const std::shared_ptr<sscl::ComponentThread> &thread)
: PuppetComponent(static_cast<PuppetApplication&>(parent), thread) : sscl::PuppetComponent(static_cast<sscl::PuppetApplication&>(parent), thread)
{ {
} }
+5 -5
View File
@@ -74,10 +74,10 @@ static std::optional<std::string> searchForLibInSmoSearchPaths(
return std::nullopt; return std::nullopt;
} }
/* Local static function to wrap ComponentThread::getSelf for SmoCallbacks */ /* Local static function to wrap sscl::ComponentThread::getSelf for SmoCallbacks */
static std::shared_ptr<ComponentThread> ComponentThread_getSelf() static std::shared_ptr<sscl::ComponentThread> ComponentThread_getSelf()
{ {
return ComponentThread::getSelf(); return sscl::ComponentThread::getSelf();
} }
/* Local static function to wrap OptionParser::getOptions for SmoCallbacks */ /* Local static function to wrap OptionParser::getOptions for SmoCallbacks */
@@ -145,7 +145,7 @@ std::optional<std::string> StimBuffApiManager::searchForLibInSmoSearchPaths(
StimBuffApiLib& StimBuffApiManager::loadStimBuffApiLib( StimBuffApiLib& StimBuffApiManager::loadStimBuffApiLib(
const std::string& libraryPath, const std::string& libraryPath,
const std::shared_ptr<ComponentThread>& componentThread const std::shared_ptr<sscl::ComponentThread>& componentThread
) )
{ {
std::optional<std::string> fullPath = searchForLibInSmoSearchPaths( std::optional<std::string> fullPath = searchForLibInSmoSearchPaths(
@@ -252,7 +252,7 @@ void StimBuffApiManager::unloadAllStimBuffApiLibs(void)
} }
void StimBuffApiManager::loadAllStimBuffApiLibsFromOptions( void StimBuffApiManager::loadAllStimBuffApiLibsFromOptions(
const std::shared_ptr<ComponentThread>& componentThread const std::shared_ptr<sscl::ComponentThread>& componentThread
) )
{ {
const auto& options = OptionParser::getOptions(); const auto& options = OptionParser::getOptions();
@@ -71,7 +71,7 @@ bool IoUringAssemblyEngine::setup()
{ {
// Defensive check to prevent double-calling // Defensive check to prevent double-calling
{ {
SpinLock::Guard lock(shouldAcceptRequestsLock); sscl::SpinLock::Guard lock(shouldAcceptRequestsLock);
if (shouldAcceptRequests) if (shouldAcceptRequests)
{ {
throw std::runtime_error(std::string(__func__) + ": setup() called " throw std::runtime_error(std::string(__func__) + ": setup() called "
@@ -180,7 +180,7 @@ void IoUringAssemblyEngine::finalize()
{ {
auto& ioService = smoHooksPtr->ComponentThread_getSelf()->getIoService(); auto& ioService = smoHooksPtr->ComponentThread_getSelf()->getIoService();
AsynchronousBridge bridge(ioService); sscl::AsynchronousBridge bridge(ioService);
boost::asio::deadline_timer timeoutTimer(ioService); boost::asio::deadline_timer timeoutTimer(ioService);
/** EXPLANATION: /** EXPLANATION:
@@ -329,7 +329,7 @@ void IoUringAssemblyEngine::resetAndAssembleFrame(
bool IoUringAssemblyEngine::stop() bool IoUringAssemblyEngine::stop()
{ {
// Acquire and release lock tightly around setting the flag // Acquire and release lock tightly around setting the flag
SpinLock::Guard lock(shouldAcceptRequestsLock); sscl::SpinLock::Guard lock(shouldAcceptRequestsLock);
bool wasAcceptingRequests = shouldAcceptRequests; bool wasAcceptingRequests = shouldAcceptRequests;
shouldAcceptRequests = false; shouldAcceptRequests = false;
return wasAcceptingRequests; return wasAcceptingRequests;
@@ -427,22 +427,22 @@ cleanup_eventfd:
// Continuation class for assembleFrameReq // Continuation class for assembleFrameReq
class IoUringAssemblyEngine::AssembleFrameReq class IoUringAssemblyEngine::AssembleFrameReq
: public PostedAsynchronousContinuation< : public sscl::PostedAsynchronousContinuation<
IoUringAssemblyEngine::assembleFrameReqCbFn> IoUringAssemblyEngine::assembleFrameReqCbFn>
{ {
public: public:
AssembleFrameReq( AssembleFrameReq(
IoUringAssemblyEngine& engine_, IoUringAssemblyEngine& engine_,
const std::shared_ptr<ComponentThread>& caller, const std::shared_ptr<sscl::ComponentThread>& caller,
Callback<IoUringAssemblyEngine::assembleFrameReqCbFn> cb) sscl::Callback<IoUringAssemblyEngine::assembleFrameReqCbFn> cb)
: PostedAsynchronousContinuation< : sscl::PostedAsynchronousContinuation<
IoUringAssemblyEngine::assembleFrameReqCbFn>(caller, cb), IoUringAssemblyEngine::assembleFrameReqCbFn>(caller, cb),
engine(engine_), engine(engine_),
loop(engine_.frameAssemblyDesc->numSlots), loop(engine_.frameAssemblyDesc->numSlots),
timerFired(false), handlerExecuted(false) timerFired(false), handlerExecuted(false)
{} {}
void callOriginalCallback(bool success, AsynchronousLoop loop) void callOriginalCallback(bool success, sscl::AsynchronousLoop loop)
{ {
callOriginalCb(success, loop); callOriginalCb(success, loop);
} }
@@ -451,16 +451,16 @@ public:
void assembleFrameReq1_posted( void assembleFrameReq1_posted(
std::shared_ptr<AssembleFrameReq> context) std::shared_ptr<AssembleFrameReq> context)
{ {
SpinLock::Guard lock(engine.shouldAcceptRequestsLock); sscl::SpinLock::Guard lock(engine.shouldAcceptRequestsLock);
if (!engine.shouldAcceptRequests) if (!engine.shouldAcceptRequests)
{ {
context->callOriginalCallback(false, AsynchronousLoop(0)); context->callOriginalCallback(false, sscl::AsynchronousLoop(0));
return; return;
} }
// Initialize loop with number of slots // Initialize loop with number of slots
context->loop = AsynchronousLoop(engine.frameAssemblyDesc->numSlots); context->loop = sscl::AsynchronousLoop(engine.frameAssemblyDesc->numSlots);
// Record assembly start time // Record assembly start time
engine.assemblyStartTime = std::chrono::high_resolution_clock::now(); 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 * indeed seen a SEGFAULT even in the current code with locking, so
* I'm going to hold the lock here for now. * 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) if (!context->engine.shouldAcceptRequests)
{ {
@@ -636,19 +636,19 @@ public:
public: public:
IoUringAssemblyEngine& engine; IoUringAssemblyEngine& engine;
AsynchronousLoop loop; sscl::AsynchronousLoop loop;
std::atomic<bool> timerFired; std::atomic<bool> timerFired;
std::atomic<bool> handlerExecuted; std::atomic<bool> handlerExecuted;
}; };
void IoUringAssemblyEngine::assembleFrameReq( void IoUringAssemblyEngine::assembleFrameReq(
Callback<assembleFrameReqCbFn> cb) sscl::Callback<assembleFrameReqCbFn> cb)
{ {
{ {
SpinLock::Guard lock(shouldAcceptRequestsLock); sscl::SpinLock::Guard lock(shouldAcceptRequestsLock);
if (!shouldAcceptRequests) if (!shouldAcceptRequests)
{ {
cb.callbackFn(false, AsynchronousLoop(0)); cb.callbackFn(false, sscl::AsynchronousLoop(0));
return; return;
} }
} }
@@ -677,7 +677,7 @@ void IoUringAssemblyEngine::onEventfdRead(
* IoUringAssemblyEngine's per-assembly state isn't destroyed while this * IoUringAssemblyEngine's per-assembly state isn't destroyed while this
* handler is running. * handler is running.
*/ */
SpinLock::Guard lock(shouldAcceptRequestsLock); sscl::SpinLock::Guard lock(shouldAcceptRequestsLock);
/** EXPLANATION: /** EXPLANATION:
* You'd think we should put check for shouldAcceptRequests here and * You'd think we should put check for shouldAcceptRequests here and
* `return` here if !shouldAcceptRequests, but we shouldn't because * `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) if (!frameAssemblyDesc)
{ return; } { return; }
@@ -816,7 +816,7 @@ void IoUringAssemblyEngine::randomDummySlotFiller(AsynchronousLoop& loop)
numDummiesToCreate = dummiesCreated; 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, // Since we only reach here when nSucceeded == nTotal and nFailed == 0,
// we can directly calculate the new values // we can directly calculate the new values
uint32_t newSucceeded = nTotal - static_cast<uint32_t>(numDummiesToCreate); uint32_t newSucceeded = nTotal - static_cast<uint32_t>(numDummiesToCreate);
@@ -40,8 +40,8 @@ public:
bool setup(); bool setup();
void finalize(); void finalize();
typedef std::function<void(bool, AsynchronousLoop)> assembleFrameReqCbFn; typedef std::function<void(bool, sscl::AsynchronousLoop)> assembleFrameReqCbFn;
void assembleFrameReq(Callback<assembleFrameReqCbFn> cb); void assembleFrameReq(sscl::Callback<assembleFrameReqCbFn> cb);
// Telemetry helpers // Telemetry helpers
static size_t computePointsPerFrame(int returnMode, size_t nDgramsPerFrame) static size_t computePointsPerFrame(int returnMode, size_t nDgramsPerFrame)
@@ -82,7 +82,7 @@ private:
* Flag to indicate whether engine should accept new requests. * Flag to indicate whether engine should accept new requests.
* Set by setup(), cleared by stop(). * Set by setup(), cleared by stop().
*/ */
SpinLock shouldAcceptRequestsLock; sscl::SpinLock shouldAcceptRequestsLock;
bool shouldAcceptRequests; bool shouldAcceptRequests;
size_t nDgramsPerStagingBufferFrame; size_t nDgramsPerStagingBufferFrame;
@@ -106,7 +106,7 @@ private:
std::chrono::high_resolution_clock::time_point assemblyEndTime; std::chrono::high_resolution_clock::time_point assemblyEndTime;
void fillUnAssembledSlotsWithDummyDgrams(); void fillUnAssembledSlotsWithDummyDgrams();
void randomDummySlotFiller(AsynchronousLoop& loop); void randomDummySlotFiller(sscl::AsynchronousLoop& loop);
void onEventfdRead( void onEventfdRead(
const boost::system::error_code& error, std::size_t bytes_transferred); const boost::system::error_code& error, std::size_t bytes_transferred);
+9 -9
View File
@@ -119,13 +119,13 @@ LivoxProto1DllState livoxProto1;
// Continuation classes for async operations // Continuation classes for async operations
class AttachDeviceReq class AttachDeviceReq
: public smo::NonPostedAsynchronousContinuation<sal_mlo_attachDeviceReqCbFn> : public sscl::NonPostedAsynchronousContinuation<sal_mlo_attachDeviceReqCbFn>
{ {
public: public:
AttachDeviceReq( AttachDeviceReq(
const std::shared_ptr<smo::device::DeviceAttachmentSpec>& spec, const std::shared_ptr<smo::device::DeviceAttachmentSpec>& spec,
smo::Callback<sal_mlo_attachDeviceReqCbFn> cb) sscl::Callback<sal_mlo_attachDeviceReqCbFn> cb)
: smo::NonPostedAsynchronousContinuation<sal_mlo_attachDeviceReqCbFn>( : sscl::NonPostedAsynchronousContinuation<sal_mlo_attachDeviceReqCbFn>(
std::move(cb)), std::move(cb)),
spec(spec) spec(spec)
{} {}
@@ -388,14 +388,14 @@ public:
}; };
class DetachDeviceReq class DetachDeviceReq
: public smo::NonPostedAsynchronousContinuation<sal_mlo_detachDeviceReqCbFn> : public sscl::NonPostedAsynchronousContinuation<sal_mlo_detachDeviceReqCbFn>
{ {
public: public:
DetachDeviceReq( DetachDeviceReq(
const std::shared_ptr<smo::device::DeviceAttachmentSpec>& spec, const std::shared_ptr<smo::device::DeviceAttachmentSpec>& spec,
const std::shared_ptr<StimulusBuffer>& stimBuffer, const std::shared_ptr<StimulusBuffer>& stimBuffer,
smo::Callback<sal_mlo_detachDeviceReqCbFn> cb) sscl::Callback<sal_mlo_detachDeviceReqCbFn> cb)
: smo::NonPostedAsynchronousContinuation<sal_mlo_detachDeviceReqCbFn>( : sscl::NonPostedAsynchronousContinuation<sal_mlo_detachDeviceReqCbFn>(
std::move(cb)), std::move(cb)),
spec(spec), stimBuffer(stimBuffer) spec(spec), stimBuffer(stimBuffer)
{} {}
@@ -658,8 +658,8 @@ extern "C" int livoxGen1_finalizeInd(void)
extern "C" void livoxGen1_attachDeviceReq( extern "C" void livoxGen1_attachDeviceReq(
const std::shared_ptr<smo::device::DeviceAttachmentSpec>& desc, const std::shared_ptr<smo::device::DeviceAttachmentSpec>& desc,
const std::shared_ptr<smo::ComponentThread>& componentThread, const std::shared_ptr<sscl::ComponentThread>& componentThread,
Callback<smo::stim_buff::sal_mlo_attachDeviceReqCbFn> cb sscl::Callback<smo::stim_buff::sal_mlo_attachDeviceReqCbFn> cb
) )
{ {
if (!livoxProto1.livoxProto1_getOrCreateDeviceReq) if (!livoxProto1.livoxProto1_getOrCreateDeviceReq)
@@ -847,7 +847,7 @@ extern "C" void livoxGen1_attachDeviceReq(
extern "C" void livoxGen1_detachDeviceReq( extern "C" void livoxGen1_detachDeviceReq(
const std::shared_ptr<smo::device::DeviceAttachmentSpec>& desc, const std::shared_ptr<smo::device::DeviceAttachmentSpec>& desc,
Callback<smo::stim_buff::sal_mlo_detachDeviceReqCbFn> cb sscl::Callback<smo::stim_buff::sal_mlo_detachDeviceReqCbFn> cb
) )
{ {
// Case 1: Check if StimBuffer doesn't exist (early return) // Case 1: Check if StimBuffer doesn't exist (early return)
@@ -65,7 +65,7 @@ bool OpenClCollatingAndMeshingEngine::setup()
{ {
// Defensive check to prevent double-calling // Defensive check to prevent double-calling
{ {
SpinLock::Guard lock(shouldAcceptRequestsLock); sscl::SpinLock::Guard lock(shouldAcceptRequestsLock);
if (shouldAcceptRequests) if (shouldAcceptRequests)
{ {
throw std::runtime_error(std::string(__func__) + ": setup() called " throw std::runtime_error(std::string(__func__) + ": setup() called "
@@ -224,7 +224,7 @@ void OpenClCollatingAndMeshingEngine::finalize()
int delayMs = std::max(OCLCOLLMESH_ENGN_FINALIZE_DELAY_MS, 0); int delayMs = std::max(OCLCOLLMESH_ENGN_FINALIZE_DELAY_MS, 0);
auto& ioService = smoHooksPtr->ComponentThread_getSelf()->getIoService(); auto& ioService = smoHooksPtr->ComponentThread_getSelf()->getIoService();
AsynchronousBridge bridge(ioService); sscl::AsynchronousBridge bridge(ioService);
boost::asio::deadline_timer timeoutTimer(ioService); boost::asio::deadline_timer timeoutTimer(ioService);
/** EXPLANATION: /** EXPLANATION:
@@ -763,7 +763,7 @@ bool OpenClCollatingAndMeshingEngine::setupCollateDgramsArgs(
bool OpenClCollatingAndMeshingEngine::stop() bool OpenClCollatingAndMeshingEngine::stop()
{ {
// Acquire and release lock tightly around setting the flag // Acquire and release lock tightly around setting the flag
SpinLock::Guard lock(shouldAcceptRequestsLock); sscl::SpinLock::Guard lock(shouldAcceptRequestsLock);
bool wasAcceptingRequests = shouldAcceptRequests; bool wasAcceptingRequests = shouldAcceptRequests;
shouldAcceptRequests = false; shouldAcceptRequests = false;
return wasAcceptingRequests; return wasAcceptingRequests;
@@ -1015,11 +1015,11 @@ void OpenClCollatingAndMeshingEngine::produceAmbienceStimulusFrame(
} }
class OpenClCollatingAndMeshingEngine::CompactCollateAndMeshFrameReq class OpenClCollatingAndMeshingEngine::CompactCollateAndMeshFrameReq
: public PostedAsynchronousContinuation<compactCollateAndMeshFrameReqCbFn> : public sscl::PostedAsynchronousContinuation<compactCollateAndMeshFrameReqCbFn>
{ {
private: private:
OpenClCollatingAndMeshingEngine& engine; OpenClCollatingAndMeshingEngine& engine;
AsynchronousLoop frameAssemblyResult; sscl::AsynchronousLoop frameAssemblyResult;
StimulusFrame& stimulusFrame; StimulusFrame& stimulusFrame;
std::optional<std::reference_wrapper<StimulusFrame>> intensityStimFrame; std::optional<std::reference_wrapper<StimulusFrame>> intensityStimFrame;
std::optional<std::reference_wrapper<StimulusFrame>> ambienceStimFrame; std::optional<std::reference_wrapper<StimulusFrame>> ambienceStimFrame;
@@ -1027,13 +1027,13 @@ private:
public: public:
CompactCollateAndMeshFrameReq( CompactCollateAndMeshFrameReq(
OpenClCollatingAndMeshingEngine& engine_, OpenClCollatingAndMeshingEngine& engine_,
AsynchronousLoop& asyncLoop, sscl::AsynchronousLoop& asyncLoop,
StimulusFrame& stimulusFrame_, StimulusFrame& stimulusFrame_,
std::optional<std::reference_wrapper<StimulusFrame>> intensityStimFrame_, std::optional<std::reference_wrapper<StimulusFrame>> intensityStimFrame_,
std::optional<std::reference_wrapper<StimulusFrame>> ambienceStimFrame_, std::optional<std::reference_wrapper<StimulusFrame>> ambienceStimFrame_,
const std::shared_ptr<ComponentThread>& caller, const std::shared_ptr<sscl::ComponentThread>& caller,
Callback<compactCollateAndMeshFrameReqCbFn> cb) sscl::Callback<compactCollateAndMeshFrameReqCbFn> cb)
: PostedAsynchronousContinuation<compactCollateAndMeshFrameReqCbFn>( : sscl::PostedAsynchronousContinuation<compactCollateAndMeshFrameReqCbFn>(
caller, cb), caller, cb),
engine(engine_), engine(engine_),
frameAssemblyResult(asyncLoop), stimulusFrame(stimulusFrame_), frameAssemblyResult(asyncLoop), stimulusFrame(stimulusFrame_),
@@ -1049,7 +1049,7 @@ public:
void compactCollateAndMeshFrameReq1_doCompact_posted( void compactCollateAndMeshFrameReq1_doCompact_posted(
std::shared_ptr<CompactCollateAndMeshFrameReq> context) std::shared_ptr<CompactCollateAndMeshFrameReq> context)
{ {
SpinLock::Guard lock(engine.shouldAcceptRequestsLock); sscl::SpinLock::Guard lock(engine.shouldAcceptRequestsLock);
if (!engine.shouldAcceptRequests) if (!engine.shouldAcceptRequests)
{ {
callOriginalCallback(false); callOriginalCallback(false);
@@ -1080,7 +1080,7 @@ public:
std::shared_ptr<CompactCollateAndMeshFrameReq> context, std::shared_ptr<CompactCollateAndMeshFrameReq> context,
cl_int compactStatus) cl_int compactStatus)
{ {
SpinLock::Guard lock(engine.shouldAcceptRequestsLock); sscl::SpinLock::Guard lock(engine.shouldAcceptRequestsLock);
if (!engine.shouldAcceptRequests) if (!engine.shouldAcceptRequests)
{ {
/** EXPLANATION: /** EXPLANATION:
@@ -1121,7 +1121,7 @@ public:
void compactCollateAndMeshFrameReq3_doCollate_posted( void compactCollateAndMeshFrameReq3_doCollate_posted(
std::shared_ptr<CompactCollateAndMeshFrameReq> context) std::shared_ptr<CompactCollateAndMeshFrameReq> context)
{ {
SpinLock::Guard lock(engine.shouldAcceptRequestsLock); sscl::SpinLock::Guard lock(engine.shouldAcceptRequestsLock);
if (!engine.shouldAcceptRequests) if (!engine.shouldAcceptRequests)
{ {
callOriginalCallback(false); callOriginalCallback(false);
@@ -1153,7 +1153,7 @@ public:
[[maybe_unused]] std::shared_ptr<CompactCollateAndMeshFrameReq> context, [[maybe_unused]] std::shared_ptr<CompactCollateAndMeshFrameReq> context,
cl_int collateStatus) cl_int collateStatus)
{ {
SpinLock::Guard lock(engine.shouldAcceptRequestsLock); sscl::SpinLock::Guard lock(engine.shouldAcceptRequestsLock);
if (!engine.shouldAcceptRequests) if (!engine.shouldAcceptRequests)
{ {
/* We intentionally don't call collateKernelComplete() here for the /* We intentionally don't call collateKernelComplete() here for the
@@ -1273,13 +1273,13 @@ public:
}; };
void OpenClCollatingAndMeshingEngine::compactCollateAndMeshFrameReq( void OpenClCollatingAndMeshingEngine::compactCollateAndMeshFrameReq(
AsynchronousLoop& asyncLoop, StimulusFrame& stimulusFrame, sscl::AsynchronousLoop& asyncLoop, StimulusFrame& stimulusFrame,
std::optional<std::reference_wrapper<StimulusFrame>> intensityStimFrame, std::optional<std::reference_wrapper<StimulusFrame>> intensityStimFrame,
std::optional<std::reference_wrapper<StimulusFrame>> ambienceStimFrame, std::optional<std::reference_wrapper<StimulusFrame>> ambienceStimFrame,
Callback<compactCollateAndMeshFrameReqCbFn> callback) sscl::Callback<compactCollateAndMeshFrameReqCbFn> callback)
{ {
{ {
SpinLock::Guard lock(shouldAcceptRequestsLock); sscl::SpinLock::Guard lock(shouldAcceptRequestsLock);
if (!shouldAcceptRequests) if (!shouldAcceptRequests)
{ {
callback.callbackFn(false, stimulusFrame); callback.callbackFn(false, stimulusFrame);
@@ -78,10 +78,10 @@ public:
typedef std::function<void(bool, StimulusFrame&)> typedef std::function<void(bool, StimulusFrame&)>
compactCollateAndMeshFrameReqCbFn; compactCollateAndMeshFrameReqCbFn;
void compactCollateAndMeshFrameReq( void compactCollateAndMeshFrameReq(
AsynchronousLoop& asyncLoop, StimulusFrame& stimulusFrame, sscl::AsynchronousLoop& asyncLoop, StimulusFrame& stimulusFrame,
std::optional<std::reference_wrapper<StimulusFrame>> intensityStimFrame, std::optional<std::reference_wrapper<StimulusFrame>> intensityStimFrame,
std::optional<std::reference_wrapper<StimulusFrame>> ambienceStimFrame, std::optional<std::reference_wrapper<StimulusFrame>> ambienceStimFrame,
Callback<compactCollateAndMeshFrameReqCbFn> callback); sscl::Callback<compactCollateAndMeshFrameReqCbFn> callback);
private: private:
// Callback function types // Callback function types
@@ -133,7 +133,7 @@ private:
cl_mem clAverageIntensityBuffer; cl_mem clAverageIntensityBuffer;
// State tracking // State tracking
SpinLock shouldAcceptRequestsLock; sscl::SpinLock shouldAcceptRequestsLock;
bool shouldAcceptRequests; bool shouldAcceptRequests;
bool compactIsRunning; bool compactIsRunning;
bool collateIsRunning; bool collateIsRunning;
@@ -362,11 +362,11 @@ void PcloudStimulusProducer::stimFrameProductionTimesliceInd()
} }
class PcloudStimulusProducer::ProduceFrameReq class PcloudStimulusProducer::ProduceFrameReq
: public PostedAsynchronousContinuation<produceFrameReqCbFn> : public sscl::PostedAsynchronousContinuation<produceFrameReqCbFn>
{ {
private: private:
PcloudStimulusProducer& pcloudProducer; PcloudStimulusProducer& pcloudProducer;
AsynchronousLoop frameAssemblyResult; sscl::AsynchronousLoop frameAssemblyResult;
StimulusFrame& stimulusFrame; StimulusFrame& stimulusFrame;
std::optional<std::reference_wrapper<StimulusFrame>> intensityStimFrame; std::optional<std::reference_wrapper<StimulusFrame>> intensityStimFrame;
std::optional<std::reference_wrapper<StimulusFrame>> ambienceStimFrame; std::optional<std::reference_wrapper<StimulusFrame>> ambienceStimFrame;
@@ -374,9 +374,9 @@ private:
public: public:
ProduceFrameReq( ProduceFrameReq(
PcloudStimulusProducer& producer, PcloudStimulusProducer& producer,
const std::shared_ptr<ComponentThread>& caller, const std::shared_ptr<sscl::ComponentThread>& caller,
Callback<produceFrameReqCbFn> cb) sscl::Callback<produceFrameReqCbFn> cb)
: PostedAsynchronousContinuation<produceFrameReqCbFn>(caller, cb), : sscl::PostedAsynchronousContinuation<produceFrameReqCbFn>(caller, cb),
pcloudProducer(producer), pcloudProducer(producer),
frameAssemblyResult(0), frameAssemblyResult(0),
stimulusFrame(producer.tempStimulusFrame) stimulusFrame(producer.tempStimulusFrame)
@@ -393,7 +393,7 @@ public:
void produceFrameReq1_doAssemble_posted( void produceFrameReq1_doAssemble_posted(
std::shared_ptr<ProduceFrameReq> context) std::shared_ptr<ProduceFrameReq> context)
{ {
SpinLock::Guard lock(pcloudProducer.shouldContinueLock); sscl::SpinLock::Guard lock(pcloudProducer.shouldContinueLock);
if (!pcloudProducer.shouldContinue) if (!pcloudProducer.shouldContinue)
{ {
callOriginalCallback(); callOriginalCallback();
@@ -409,9 +409,9 @@ public:
void produceFrameReq2_assembleDone( void produceFrameReq2_assembleDone(
std::shared_ptr<ProduceFrameReq> context, std::shared_ptr<ProduceFrameReq> context,
bool success, AsynchronousLoop loop) bool success, sscl::AsynchronousLoop loop)
{ {
SpinLock::Guard lock(pcloudProducer.shouldContinueLock); sscl::SpinLock::Guard lock(pcloudProducer.shouldContinueLock);
if (!pcloudProducer.shouldContinue) if (!pcloudProducer.shouldContinue)
{ {
callOriginalCallback(); callOriginalCallback();
@@ -490,7 +490,7 @@ public:
context->ambienceStimFrame->get().lock.writeRelease(); context->ambienceStimFrame->get().lock.writeRelease();
} }
SpinLock::Guard lock(pcloudProducer.shouldContinueLock); sscl::SpinLock::Guard lock(pcloudProducer.shouldContinueLock);
if (!pcloudProducer.shouldContinue) if (!pcloudProducer.shouldContinue)
{ {
callOriginalCallback(); callOriginalCallback();
@@ -517,7 +517,7 @@ public:
}; };
void PcloudStimulusProducer::produceFrameReq( void PcloudStimulusProducer::produceFrameReq(
smo::Callback<produceFrameReqCbFn> callback) sscl::Callback<produceFrameReqCbFn> callback)
{ {
/** EXPLANATION: /** EXPLANATION:
* We shouldn't acquire the StimulusProducer::shouldContinueLock here because * We shouldn't acquire the StimulusProducer::shouldContinueLock here because
@@ -80,7 +80,7 @@ protected:
typedef std::function<void()> produceFrameReqCbFn; typedef std::function<void()> produceFrameReqCbFn;
public: public:
void produceFrameReq(smo::Callback<produceFrameReqCbFn> callback); void produceFrameReq(sscl::Callback<produceFrameReqCbFn> callback);
size_t nDgramsPerStagingBufferFrame; size_t nDgramsPerStagingBufferFrame;
std::shared_ptr<livoxProto1::Device> device; std::shared_ptr<livoxProto1::Device> device;
+3 -3
View File
@@ -276,8 +276,8 @@ static int xcbWindow_finalizeInd(void)
static void xcbWindow_attachDeviceReq( static void xcbWindow_attachDeviceReq(
const std::shared_ptr<smo::device::DeviceAttachmentSpec>& desc, const std::shared_ptr<smo::device::DeviceAttachmentSpec>& desc,
const std::shared_ptr<smo::ComponentThread>& componentThread, const std::shared_ptr<sscl::ComponentThread>& componentThread,
smo::Callback<smo::stim_buff::sal_mlo_attachDeviceReqCbFn> cb sscl::Callback<smo::stim_buff::sal_mlo_attachDeviceReqCbFn> cb
) )
{ {
// Not used yet, but may be used later. // Not used yet, but may be used later.
@@ -302,7 +302,7 @@ static void xcbWindow_attachDeviceReq(
static void xcbWindow_detachDeviceReq( static void xcbWindow_detachDeviceReq(
const std::shared_ptr<smo::device::DeviceAttachmentSpec>& spec, const std::shared_ptr<smo::device::DeviceAttachmentSpec>& spec,
smo::Callback<smo::stim_buff::sal_mlo_detachDeviceReqCbFn> cb sscl::Callback<smo::stim_buff::sal_mlo_detachDeviceReqCbFn> cb
) )
{ {
auto it = std::find_if(g_attachedWindows.begin(), g_attachedWindows.end(), auto it = std::find_if(g_attachedWindows.begin(), g_attachedWindows.end(),
+3 -3
View File
@@ -15,10 +15,10 @@ public:
: LockerAndInvokerBase(addr), awakened(false) {} : LockerAndInvokerBase(addr), awakened(false) {}
bool awakened; bool awakened;
Qutex* registeredQutex = nullptr; sscl::Qutex* registeredQutex = nullptr;
List::iterator queueIterator; List::iterator queueIterator;
List::iterator getLockvokerIteratorForQutex(Qutex& qutex) override { List::iterator getLockvokerIteratorForQutex(sscl::Qutex& qutex) override {
registeredQutex = &qutex; registeredQutex = &qutex;
queueIterator = qutex.registerInQueue(std::shared_ptr<LockerAndInvokerBase>(this)); queueIterator = qutex.registerInQueue(std::shared_ptr<LockerAndInvokerBase>(this));
return queueIterator; return queueIterator;
@@ -44,7 +44,7 @@ protected:
// Clean up // Clean up
} }
Qutex qutex; sscl::Qutex qutex;
std::shared_ptr<MockLockerAndInvoker> mock1, mock2, mock3, mock4, mock5; std::shared_ptr<MockLockerAndInvoker> mock1, mock2, mock3, mock4, mock5;
// Unique addresses for testing // Unique addresses for testing