23using namespace std::chrono_literals;
53 if (
status == std::future_status::ready)
67 <<
"] fut valid but waiting for asynchronous onEntry thread to finish: state: "
76 <<
"] waiting future onEntryThread. It was not even created. Skipping wait.");
81 rclcpp::sleep_for(100
ms);
85 "[%s] waiting for finishing client behavior, before leaving the state. Is the client "
86 "behavior stuck? requesting force finish",
92 catch (
const std::exception &
e)
96 "[SmaccAsyncClientBehavior] trying to join function, but it was already finished.");
111 getLogger(),
"[" <<
getName() <<
"] onExit - Creating asynchronous onExit thread");
126 <<
"] Destroying client behavior- Waiting finishing of asynchronous onExit "
141 "[SmaccAsyncClientBehavior] trying to Join onExit function, but it was already "
147 <<
"] Destroying client behavior- onExit thread finished. Proccedding "
161 "[" <<
getName() <<
"] " << ((
uint64_t)
this) <<
" requestForceFinish");
167 std::string
shut =
"";
std::string getName() const
virtual rclcpp::Logger getLogger() const
virtual rclcpp::Node::SharedPtr getNode() const
virtual ~SmaccAsyncClientBehavior()
bool isShutdownRequested_
std::function< void()> postSuccessEventFn_
std::function< void()> postFinishEventFn_
void executeOnEntry() override
bool isShutdownRequested()
onEntry is executed in a new thread. However the current state cannot be left until the onEntry threa...
virtual void dispose() override
std::optional< std::future< int > > onExitThread_
std::optional< std::future< int > > onEntryThread_
void waitFutureIfNotFinished(std::optional< std::future< int > > &threadfut, bool requestFinish)
void requestForceFinish()
void executeOnExit() override
std::function< void()> postFailureEventFn_
void waitOnEntryThread(bool requestFinish)