Skip to content

Commit

Permalink
Enable to set connection context without changing deleter.
Browse files Browse the repository at this point in the history
  • Loading branch information
Barenboim committed Jan 13, 2025
1 parent 05ee611 commit 720341f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/factory/WFConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ class WFConnection : public CommConnection
this->deleter = std::move(deleter);
}

void set_context(void *context)
{
this->context = context;
}

void *test_set_context(void *test_context, void *new_context,
std::function<void (void *)> deleter)
{
Expand All @@ -50,6 +55,14 @@ class WFConnection : public CommConnection
return test_context;
}

void *test_set_context(void *test_context, void *new_context)
{
if (this->context.compare_exchange_strong(test_context, new_context))
return new_context;

return test_context;
}

private:
std::atomic<void *> context;
std::function<void (void *)> deleter;
Expand Down

0 comments on commit 720341f

Please sign in to comment.