Skip to content

Commit

Permalink
Fix thread-safety (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
muukii authored Jul 7, 2023
1 parent f1fecaf commit 3ddc450
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions Sources/Bulk/Core/BulkSink.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ public final class BulkSink<Element>: BulkSinkType {

guard let self else { return }

let elements = buffer.purge()

self.targets.forEach {
$0.write(items: elements)
self.targetQueue.async { [self] in
let elements = buffer.purge()

self.targets.forEach {
$0.write(items: elements)
}

self.timer.tap()
}

self.timer.tap()
}

}
Expand Down

0 comments on commit 3ddc450

Please sign in to comment.