Skip to content

Commit 7778dd3

Browse files
committed
Add some brief explanation for the alteration of the Element in the buffer to an UnsafeTransfer
1 parent 7ce45c1 commit 7778dd3

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

Sources/AsyncAlgorithms/Buffer/AsyncBufferSequence.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,14 @@ public struct AsyncBufferSequencePolicy: Sendable {
7474
/// An `AsyncSequence` that buffers elements in regard to a policy.
7575
@available(AsyncAlgorithms 1.0, *)
7676
public struct AsyncBufferSequence<Base: AsyncSequence & Sendable>: AsyncSequence {
77+
// Internal implementation note:
78+
// This type origianlly had no requirement that the element is actually Sendable. However,
79+
// that is technically an implementation detail hole in the safety of the system, it needs
80+
// to specify that the element is actually Sendable since the draining mechanism passes
81+
// through the isolation that is in nature sending but cannot be marked as such for the
82+
// isolated next method.
83+
// In practice the users of this type are safe from isolation crossing since the Element
84+
// is as sendable as it is required by the base sequences the buffer is constructed from.
7785
enum StorageType {
7886
case transparent(Base.AsyncIterator)
7987
case bounded(storage: BoundedBufferStorage<Base>)

0 commit comments

Comments
 (0)