Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-9631] Extend dispatchPrecondition with context parameters. #626

Open
DevAndArtist mannequin opened this issue Jan 10, 2019 · 0 comments
Open

[SR-9631] Extend dispatchPrecondition with context parameters. #626

DevAndArtist mannequin opened this issue Jan 10, 2019 · 0 comments

Comments

@DevAndArtist
Copy link
Mannequin

@DevAndArtist DevAndArtist mannequin commented Jan 10, 2019

Previous ID SR-9631
Radar None
Original Reporter @DevAndArtist
Type Improvement
Additional Detail from JIRA
Votes 0
Component/s libdispatch
Labels Improvement
Assignee None
Priority Medium

md5: e24006469dbf42660effda4f02808744

Issue Description:

public func dispatchPrecondition(condition: @autoclosure () -> DispatchPredicate)

Is a great function to prove correct scheduling behavior, but it completely lacks of context. In my particular case I have to nest that function into an operator for an `Observable` type which works asynchronously. Whenever the precondition triggers I have no information where the issue was raised because as already mentioned `dispatchPrecondition` must be nested.

In local development I can manually print `#function` and similar before calling `dispatchPrecondition` which will give me the right context, but this solution is far from ideal and cannot be captured in a real crash on a released application.

I would like to propose an addition of context parameters for `dispatchPrecondition` which will be printed when the execution traps.

public func dispatchPrecondition(
  condition: @autoclosure () -> DispatchPredicate,
  message: @autoclosure () -> String = "",
  function: StaticString = #function,
  file: StaticString = #file,
  line: UInt = #line
)

That new context should be passed to the internal `_dispatch_client_assert_fail` function.

As already mentioned, it's impossible to workaround this problem for a released application and when nested it's impossible to obtain the context information from a crash report.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

0 participants