# Does String copy storage between actors?

**URL:** <https://forums.swift.org/t/does-string-copy-storage-between-actors/74747>\
**Category:** Using Swift\
**Tags:** actors, structured-concurren\
**Created:** [September 19, 2024, 3:24pm UTC](https://forums.swift.org/t/does-string-copy-storage-between-actors/74747 "2024-09-19T15:24:00Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![AlexanderM](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/alexanderm/32/9781_2.png) [@AlexanderM](https://forums.swift.org/u/AlexanderM)\
**Post date:** [September 19, 2024, 4:20pm UTC](https://forums.swift.org/t/does-string-copy-storage-between-actors/74747/3 "2024-09-19T16:20:15Z")

</div>

> [@Max\_Desiatov](#):
>
> I'd expect `isKnownUniquelyReferenced` in CoW containers under the hood is used to check an atomic reference count on modification universally, including concurrent access, which is why it is atomic in the first place.

Correct! It's thread-safe by virtue of the reference counting being synchronized already. It's just doing a single check, and doesn't also modify the ref count, so there's no [TOC/TOU](https://en.wikipedia.org/wiki/Time-of-check_to_time-of-use) concerns.

By the time you're able to call `isKnownUniquelyReferenced(x)`, you've got a strong reference to `x`. At that point, it can check if the reference count is `>1`, indicating that some other reference must exist.

Here's an enlightening thread on this matter: [isKnownUniquelyReferenced thread safety](https://forums.swift.org/t/isknownuniquelyreferenced-thread-safety/22933)

---

_[View the full topic](https://forums.swift.org/t/does-string-copy-storage-between-actors/74747)._
