digitalmars.D - Thread safe reference counting
- Kagamin (3/3) Feb 03 2018 That RCSharedAllocator PR made me think, so this is my take on
- Nathan S. (5/8) Feb 06 2018 You might also want to look at Atila Neves's automem package. It
- Kagamin (3/7) Feb 06 2018 That RefCounted only counts on stack, it can't be put in shared
- Atila Neves (7/15) Feb 07 2018 There are some bugs with shared at the moment in dmd (I
- Kagamin (5/6) Feb 07 2018 If you rely only on postblit, then you can't concurrently read
That RCSharedAllocator PR made me think, so this is my take on how to keep reference counted allocator in shared storage: https://run.dlang.io/is/r1z1dd
Feb 03 2018
On Saturday, 3 February 2018 at 14:41:06 UTC, Kagamin wrote:That RCSharedAllocator PR made me think, so this is my take on how to keep reference counted allocator in shared storage: https://run.dlang.io/is/r1z1ddYou might also want to look at Atila Neves's automem package. It uses atomic increment/decrement when the type being reference-counted is `shared`. https://dlang.org/blog/2017/04/28/automem-hands-free-raii-for-d/
Feb 06 2018
On Tuesday, 6 February 2018 at 10:01:28 UTC, Nathan S. wrote:You might also want to look at Atila Neves's automem package. It uses atomic increment/decrement when the type being reference-counted is `shared`. https://dlang.org/blog/2017/04/28/automem-hands-free-raii-for-d/That RefCounted only counts on stack, it can't be put in shared storage.
Feb 06 2018
On Wednesday, 7 February 2018 at 07:58:42 UTC, Kagamin wrote:On Tuesday, 6 February 2018 at 10:01:28 UTC, Nathan S. wrote:There are some bugs with shared at the moment in dmd (I introduced a bug fixing a different bug and now I'm trying to figure out what the best way out of this mess is), so what I'm saying might not compile right now but should: auto ptr = new shared RefCounted!(...); AtilaYou might also want to look at Atila Neves's automem package. It uses atomic increment/decrement when the type being reference-counted is `shared`. https://dlang.org/blog/2017/04/28/automem-hands-free-raii-for-d/That RefCounted only counts on stack, it can't be put in shared storage.
Feb 07 2018
On Wednesday, 7 February 2018 at 14:09:51 UTC, Atila Neves wrote:auto ptr = new shared RefCounted!(...);If you rely only on postblit, then you can't concurrently read and write to refcounted shared storage without additional mutex lock, so it should be at least a non-copyable container (similar to what rust does).
Feb 07 2018