~smspillaz/folly/folly-git-master

Viewing all changes in revision 6598.

  • Committer: Facebook Github Bot
  • Author(s): Maged Michael
  • Date: 2019-01-19 00:57:01 UTC
  • Revision ID: git-v1:d5be302c1d4e61bcdfd829ec7dbe29709978f4e5
LifoSemMPMCQueue: Throw only when queue is full not when consumer is in progress.

Summary:
This change ensures that LifoSemMPMCQueue and PriorityLifoSemMPMCQueue do not throw unless the queue is full.

Before this change it was possible for an add operation to throw even when the queue is not full, if a consumer operation is delayed while in progress.

Example:
Queue of size N.
T1: Producer completes N add operations.
T2: Consumer starts a take operation and gets delayed.
T3: Consumer completes N-1 take operations.
T1: Tries an add operation. If using MPMCQueue::write (which returns false) throws even though the queue is not full (has N-1 empty slots). If using MPMCQueue::writeIfNotFull() returns true after waiting for T2's take to complete.

This is somewhat similar to BugD3527722.

Reviewed By: djwatson

Differential Revision: D13701978

fbshipit-source-id: a799353c41d0dc6e673b5fe0ad2a64fd5440fbe8

expand all expand all

Show diffs side-by-side

added added

removed removed

Lines of Context: