# Pitch: Protocol-based Actor Isolation

**URL:** <https://forums.swift.org/t/pitch-protocol-based-actor-isolation/41677>\
**Category:** Pitches\
**Created:** [November 1, 2020, 4:12pm UTC](https://forums.swift.org/t/pitch-protocol-based-actor-isolation/41677 "2020-11-01T16:12:06Z")\
**Posts on this page:** 1\
**Showing post:** 70

<div class="post-metadata">

**Author:** ![Douglas\_Gregor](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/douglas_gregor/32/1362_2.png) [@Douglas\_Gregor](https://forums.swift.org/u/Douglas_Gregor)\
**Post date:** [November 16, 2020, 7:16am UTC](https://forums.swift.org/t/pitch-protocol-based-actor-isolation/41677/70 "2020-11-16T07:16:04Z")

</div>

> [@xwu](#):
>
> I’m interested in how you’d feel about the option of _not_ having a marker protocol for “actor-sendability,” but rather (as in the case of `CustomStringConvertible` ) exposing _only_ a protocol for _custom_ implicit work at actor boundaries.

The thing with `CustomStringConvertible` is that we pay a very high cost for the existence of this protocol. Any type is printable with a bunch of reflection, but every time we want to print a type we have to go look up whether it is `CustomStringConvertible` to see if there's an override. That kind of runtime lookup isn't acceptable at actor boundaries. Maybe that's not what you're suggesting?

> [@xwu](#):
>
> To my understanding, supporting such customizability is what @Chris_Lattner3 wants to make sure is available from the get-go, so that classes that can’t be supported otherwise aren’t just left out of the actor isolation story as a potential correctness footgun.

I fully expect that we'll have some kind of `UnsafeTransfer<T>` wrapper struct that you can manually put a `T` into to turn off checking. Then your call site might be something like:

```swift
otherActor.doSomething(UnsafeTransfer(myClassInstance))

```

and that's fine. You can do work in the `UnsafeTransfer` initializer.

I accept that `UnsafeTransfer` can be a property wrapper so that the "unsafe" bits are hidden in the declaration of `doSomething` if/when parameters can have property wrappers on them, e.g.,

```swift
func doSomething(@UnsafeTransfer _: MyClass) { ... }

```

and the call site won't be as obvious:

```swift
otherActor.doSomething(myClassInstance) // implicitly wrapped in UnsafeTransfer

```

because this keeps all of the custom work out of the actors mechanism.

Doug

---

_[View the full topic](https://forums.swift.org/t/pitch-protocol-based-actor-isolation/41677)._
