[libcxx-commits] [PATCH] D67086: Implement syncstream (p0053)

Marshall Clow via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Tue Dec 15 07:32:31 PST 2020


mclow.lists added inline comments.


================
Comment at: libcxx/include/syncstream:220
+{
+    mutex_ptr_type __mtx = __mtx_ptr_map[__obuf];
+
----------------
zoecarver wrote:
> zoecarver wrote:
> > mclow.lists wrote:
> > > How do entries get removed from `__mtx_ptr_map`?
> > > 
> > They don't. I don't think there is any way to say "will any threads ever need to access this streambuf again?" 
> > 
> > If there was a way to only keep the streambuf in the static map while the object is active, I would be open to that. But, I am hesitant to do that because I want to keep the read/writes to the map as low as possible. 
> > 
> > What would you suggest? 
> Given the "new" structure of `__mtx_ptr_map`, I think I can add a function to remove elements from the map safely. Would this be a good thing to add (the only reason it might not is for performance but, I think stale memory outweighs performance here)?
You could store a count, like shared_ptr does.  How many sync streams are using this streambuf?

Increment the count on construction, decrement on destruction, remove at zero.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67086/new/

https://reviews.llvm.org/D67086



More information about the libcxx-commits mailing list