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