Replies: 2 comments 6 replies
-
@cyzhou Thanks for raising this question! In general, the APIs of I don't fully understand your case yet. Few questions:
Could you copy and paste your example code here or to a GitHub repository so it can be reproduced? Thanks! |
Beta Was this translation helpful? Give feedback.
-
@cyzhou I looked at your example but I was unable to reproduce or understand it in its entirety - I think there is still some code missing. But here some general suggestions.
#include "iceoryx_hoofs/internal/concurrent/smart_lock.hpp"
using namespace iox::capro; // for ServiceDescription and IdString_t
using namespace iox::concurrent; // for smart_lock and ForwardArgsToCtor
using namespace iox::cxx; // for TruncateToCapacity
using namespace iox::popo; // for Client
smart_lock<Client<AddRequest, AddResponse>>
client(ForwardArgsToCTor, ServiceDescription{IdString_t(TruncateToCapacity, serviceName),
IdString_t(TruncateToCapacity, instanceName),
IdString_t(TruncateToCapacity, eventName)});
auto loanResult = client->loan(); // works like a shared_ptr now -> ensures that the method loan is called inside a locked mutex
if (!loanResult.has_error()) {
auto &request = loanResult.value();
// remaining code like in your example
}
// attaching to a waitset works like
myWaitset->attachEvent(client.operator->(), ClientEvent::RESPONSE_RECEIVED);
// remark client.operator->(); is really bad style but there is not yet a dereferencing operator implemented therefore it is the best solution To narrow down the deadlock you can also try to use helgrind (https://valgrind.org/docs/manual/hg-manual.html) or the thread sanitizer from gcc. |
Beta Was this translation helpful? Give feedback.
-
When I create one client in one process, and send msgs at the same time in multi-threads(using lock in sending part), then server can't send response to client after receiving one request. The error msg is "Could not deliver to client!Client is not available anymore!". I guess it may can't send response to client because client is sending msg.? So what's the right way to send msg in multi-threads, is there any demo can show this?
Beta Was this translation helpful? Give feedback.
All reactions