Introduce folly ShallowCopyRequestContextScopeGuard
Summary: This guard maintains all the RequestData pointers of the parent (through shallow copy). This allows to overwrite a specific RequestData pointer for the scope's duration, without breaking others. We decided to keep the raw ptr interface, which required to implement a pseudo shared ptr to achieve the shallow copy behaviour. Rest of the code is pretty straight forward. A few more lines than expected, due to introducing overrideContextData to avoid unecessary memory management (clearData) or warnings (setData). The performance should be neutral for code not using the guard (std::atomic incr/decr). The guard itself is pretty efficient at copying the values, though there is a slight worry about the keys (std::string). This might be a generic concern about current implementation, some form of cheap static would be better. It also calls unecessarily onSet/onUnset. I will fix on top as it makes the change more complex. Reviewed By: djwatson Differential Revision: D8911351 fbshipit-source-id: 1692428382ace1d0b79bbc84a1db50efb4c7b489
Showing
Please register or sign in to comment