3 #include <boost/lockfree/policies.hpp>
4 #include <boost/lockfree/spsc_queue.hpp>
22 boost::lockfree::spsc_queue<std::shared_ptr<RequestBase>,
23 boost::lockfree::capacity<queueSize>>
38 swap(pimpl, rhs.pimpl);
42 std::shared_ptr<RequestBase>
45 std::shared_ptr<RequestBase> request;
46 if (!pimpl->queue.pop(request))
56 request->setProcessed();
57 requestCV.notify_all();
61 RequestQueue::postRequest(
const std::shared_ptr<RequestBase>& request)
63 static std::mutex mtx;
64 std::unique_lock<std::mutex> lck(mtx);
66 if(pimpl->queue.write_available() < 10)
72 pimpl->queue.push(request);
74 [&, request]() {
return request->isProcessed() || request->hasFailed(); });
75 return !request->hasFailed();
85 std::shared_ptr<SDOUpdateRequest> request =
86 std::make_shared<SDOUpdateRequest>(sdoIdentifier, buflen, buf,
true, completeAccess);
87 return postSDOUpdateRequest(request);
96 std::shared_ptr<SDOUpdateRequest> request =
97 std::make_shared<SDOUpdateRequest>(sdoIdentifier, &buflen, buf,
false, completeAccess);
98 return postSDOUpdateRequest(request);
108 std::shared_ptr<ChangeStateRequest> request =
109 std::make_shared<ChangeStateRequest>(slaveIndex, state,
validate, actualState);
110 return postRequest(request);
117 auto request = std::make_shared<ReadStatesRequest>(state);
118 return postRequest(request);
124 auto request = std::make_shared<RegisterResetRequest>(slaveIndex);
125 return postRequest(request);
131 auto request = std::make_shared<RegisterReadRequest>(®isterData);
132 return postRequest(request);
137 std::uint16_t amountFramesToRead)
139 auto request = std::make_shared<RegisterReadRequest>(frames, amountFramesToRead);
140 return postRequest(request);
144 RequestQueue::postSDOUpdateRequest(
const std::shared_ptr<SDOUpdateRequest>& request)
146 return postRequest(request);