Skip to content

Discussion: Safety of using NS(Recursive)Lock across awaits #2

Answered by groue
KaiOelfke asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @KaiOelfke,

I migrated the issue into a discussion :-)

Thanks for opening this discussion. I am myself full of doubts, and can't pretend that the current implementation is the best possible one, or that it matches what was intended by the authors of Swift concurrency. Since the synchronization apis we need do not exist in the standard library, and that something has to be done, here we are.

I thought locking across awaits is not safe, because locks have to be unlocked on the same thread.

We're not changing thread.

The withUnsafeContinuation method accepts a closure that is documented to be immediately executed (as you have noticed). Also, it is not @escaping. The closure MUST run on …

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@KaiOelfke
Comment options

@groue
Comment options

groue Oct 7, 2022
Maintainer

@groue
Comment options

groue Oct 7, 2022
Maintainer

@rjmccall
Comment options

@groue
Comment options

groue Oct 8, 2022
Maintainer

Answer selected by KaiOelfke
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #1 on October 06, 2022 16:11.