mdavidsaver / pvxs

PVA protocol client/server library and utilities.
https://mdavidsaver.github.io/pvxs/
Other
19 stars 25 forks source link

Add client channel cache #6

Closed mdavidsaver closed 4 years ago

mdavidsaver commented 4 years ago

Maintain unused channels for 20 seconds before closing.

Uses mark+sweep style garbage collection to flag and then drop client channels which are not referenced by an operation.

This requires creating a shared_ptr reference loop between Context::Pvt (the internal reference) and Channel. This loop is explicitly broken by Context::Pvt::close() (the external reference dtor) as well as the new Context::cacheClean() and the timer callback Context::Pvt::cacheClean().