Commit Graph

3 Commits

Author SHA1 Message Date
Michelle Linington
e3e903a8ad IOS-631: Suppress message processing pipeline while we have a pending backfill operation
Creates a new root singleton: OWSMessagePipelineSupervisor

As of right now, this singleton has two responsibilities:
- Track all message processing pipeline stages that have registered
  themselves
- Post processing suspension updates to interested stages

Four classes will now register themselves as pipeline stages:
- OWSMessageContentQueue
- YAPDBMessageDecryptQueue
- IncomingGroupsV2MessageQueue
- SSKMessageDecryptJobQueue

At initialization, OWSMessagePipelineSupervisor will take out a pipeline
suspension while it waits for a UUIDBackfillTask to complete. Other
interested objects are also able to suspend the message processing
pipeline by invoking suspendMessageProcessing(for:) on the supervisor
(though, currently this is not used by anything except tests)

This also adds some supporting improvements to UnfairLock. Now,
UnfairLock closures will return the value returned from its critical
section closure.
2020-07-22 21:10:27 -07:00
Michelle Linington
5c7e82bbe3 Adopt changes from precommit linting scripts 2020-07-06 13:48:59 -07:00
Michelle Linington
5b0656060e IOS-641: Introduce various synchronization utilities
This commit adds two new synchronization utilities:

- Unfair locks: This adds an Objective-C wrapper around os_unfair_lock
  to help bridge it to Swift. (Swift's handling of the underlying C
  struct can lead to surprising TSan failures). This will be useful as a
  simple, performant lock in cases where fairness is not a concern.

- Shared serial queues: Private serial queues that are untargeted will
  target the global concurrent queues. Sometimes this is what we want,
  especially for potentially long-running work items. But for cases
  where work items are brief private serial queues risk spinning up a
  new thread.

  For private queues where the individual work items are brief and there
  isn't a more appropriate queue to target, the shared serial queues
  are a potential candidate.

This change also introduces tests for these new utilities and some QoS
management helper methods.
2020-07-06 13:48:59 -07:00