Skip to content

Commit a8840bc

Browse files
committed
Replace homebrewed smart pointer with std::shared_ptr and std::weak_ptr
Based on commit 8483354 of dumbfixes branch of 0xFEEDC0DE64 fork of ESPAsyncWebServer. Buffers to data that is sent to all clients at once are stored as a single copy of the data with multiple references to it. This usage is one for which std::shared_ptr should be used. Each client having an active std::shared_ptr to a master buffer keeps the buffer alive. Once all clients have finished using their reference, the std::weak_ptr ensures that the AsyncWebSocketMessageBuffer goes out of scope and gets invalidated. This invalidation is checked with the lock() method of the std::weak_ptr. Also some code formatting while at it. A future commit will introduce an unification between single-client buffers and multiple-client buffers in such a way that the master buffer list in the AsyncWebSocket class will be redundant and will be removed. Therefore this stage is only temporary.
1 parent 36cc1ea commit a8840bc

File tree

2 files changed

+241
-315
lines changed

2 files changed

+241
-315
lines changed

0 commit comments

Comments
 (0)