Skip to main content
a correction
Source Link
Milos
  • 619
  • 5
  • 18

The proposed approach hangs both on iOS and macOS (just not in mac targeted unit tests executed in parallel), which is fascinating in its own right. See inline comments:

The proposed approach hangs both on iOS and macOS (just not in mac targeted unit tests), which is fascinating in its own right. See inline comments:

The proposed approach hangs both on iOS and macOS (just not in unit tests executed in parallel), which is fascinating in its own right. See inline comments:

some comments on the dangers of using any such API
Source Link
Milos
  • 619
  • 5
  • 18

This, of course, is just a particular example of the fundamental reason that the use of any such API must be discouraged. Note, however, that we do already have quite a few existing APIs that are similarly discouraged, yet do exist for good reason.

A particularly relevant example is the sync method of DispatchQueue, which will cause a hang in exactly the same way if you use it to schedule a task to wait for itself. In spite of this, sync method has been put to many a good use over the years.

This, of course, is just a particular example of the fundamental reason that the use of any such API must be discouraged. Note, however, that we do already have quite a few existing APIs that are similarly discouraged, yet do exist for good reason.

A particularly relevant example is the sync method of DispatchQueue, which will cause a hang in exactly the same way if you use it to schedule a task to wait for itself. In spite of this, sync method has been put to many a good use over the years.

a caveat
Source Link
Milos
  • 619
  • 5
  • 18

Alas, a nested call would still cause a hang:

count += blocking {
    blocking { // moving to the same executor, so we hang as before
        1
    }
}

Alas, a nested call would still cause a hang:

count += blocking {
    blocking { // moving to the same executor, so we hang as before
        1
    }
}
trim
Source Link
Milos
  • 619
  • 5
  • 18
Loading
fix a typo
Source Link
Milos
  • 619
  • 5
  • 18
Loading
hangs the mac app too (just not on mac targeted unit tests)
Source Link
Milos
  • 619
  • 5
  • 18
Loading
a clarification
Source Link
Milos
  • 619
  • 5
  • 18
Loading
reduce the number of lines to fit without scrolling
Source Link
Milos
  • 619
  • 5
  • 18
Loading
Source Link
Milos
  • 619
  • 5
  • 18
Loading