Skip to content

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

Open
@DevAndArtist

Description

@DevAndArtist
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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions