Skip to content

Commit

Permalink
Call callback immediately when token was already completed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stannieman authored and fpagliughi committed Jul 4, 2024
1 parent 28477ca commit 9e378f5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/token.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,22 @@ void token::reset()
errMsg_.clear();
}

void set_action_callback(iaction_listener& listener)
{
guard g(lock_);
listener_ = &listener;

if (complete_)
{
g.unlock();

if (rc_ == MQTTASYNC_SUCCESS)
listener.on_success(*this);
else
listener.on_failure(*this);
}
}

void token::wait()
{
unique_lock g(lock_);
Expand Down

0 comments on commit 9e378f5

Please sign in to comment.