Skip to content

Conversation

@paolopas
Copy link

@paolopas paolopas commented Dec 18, 2025

Note

This is the fifth child, the code is branched from #558 (fourth child), so this one accumulate the changes.

Each commit has been checked for regressions.

  • 38c650c disclaimer notice added, final notes updated too
  • b461f49 new release method (protected) and removal of the assert in the monitor method, as it is now possible for managed connections to be released early (as described in libboostasio fully refactored #550 (comment))
  • 6e152ec minor optimizations in watcher creation and renamed Watcher::events method to set_event_mask
  • ddc1662 watcher now holds a plain pointer to the parent and no longer need the managed pointers for the strand. This makes creating callbacks a little more efficient, as you no longer have to resort to the usual juggling of the weak/shared ptrs. pair to ensure you don't have dangling pointers. I explained here why this modification, in addition to having better performance, is absolutely safe libboostasio fully refactored #550 (comment)
  • 6143b87 the example of using liboostasio has been completely rewritten, and as always it is inspired by the one relating to libev. In addition to being equipped with a disclaimer, it documents the use of the handler in more detail.
  • 4b4d592 simplified libboostasio test

I'm attaching the current version of the handler (with example test included) for anyone curious to read or experiment.

replaces get_dispatch_wrapper,
switched from boost:: to std::bind and std::function
…re#464)

appended LibBoostAsioHandler ctor parameter (with default value)
uint16_t connection_timeout = 60
slow down the heartbeat emission if the client has
already sent data within the negotiated timeout,
a similar improvement was suggested for LivEvHandler in CopernicaMarketingSoftware#550
race condition due to *_pending flags no more possible,
updated footnote with important information for handler's user
called by destructor to prevent deadlocks,
relaxed assert in monitor to allow early realeses,
final notes update
method events renamed to set_event_mask
to the parent and no longer need the managed pointers for the strand
@paolopas
Copy link
Author

paolopas commented Dec 21, 2025

A couple of class diagrams explain what happened in ddc1662 better than a lot of chatter. Before the situation was like this

classDiagram
LibBoostAsioHandler : SharedPtr~Strand~ _strand
LibBoostAsioHandler : Map~int SharedPtr~Watcher~~ _watchers
LibBoostAsioHandler *-- Watcher : _watchers
Watcher : WeakPtr~Strand~ _wpstrand
Watcher o-- LibBoostAsioHandler : _wpstrand
Loading

and this is how it is now

classDiagram
LibBoostAsioHandler : Strand _strand
LibBoostAsioHandler : Map~int SharedPtr~Watcher~~ _watchers
LibBoostAsioHandler *-- Watcher : _watchers
Watcher : LibBoostAsioHandler*  _parent
Watcher --> LibBoostAsioHandler : _parent
Loading

As you can see there is still a lot of room for improvement.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant