Open Bug 486442 Opened 15 years ago Updated 2 years ago

Will probably soon want a barrier synchronization primitive

Categories

(Core :: XPCOM, enhancement)

enhancement

Tracking

()

People

(Reporter: cjones, Unassigned)

References

Details

Attachments

(1 file)

Due to the nature of some new projects being explored, it's probably only a matter of time until we need an nsBarrier.  These usually come up in situations where parallelism is used at a fairly fine grain for performance, rather than responsiveness, as we mostly do now.

Here's a reasonable API:

  nsBarrier(int count);
  ~nsBarrier();
  /** When |count| threads arrive, all are woken up and continue.  Any thread
   * arriving before then is stalled. */
  void Wait();

Barriers can be easily implemented on top of monitors, but this is not the most efficient way.

This is very low priority.
Attached patch v1Splinter Review
Attachment #409456 - Flags: review?(benjamin)
Assignee: nobody → jones.chris.g
Status: UNCONFIRMED → NEW
Ever confirmed: true
Comment on attachment 409456 [details] [diff] [review]
v1

Barrier.h doesn't have any comments at all explaining how you'd use it, which seems like a basic prerequisite for reviewing this patch. I'd like to understand who would normally wait on a barrier... wouldn't it just be one thread waiting? Why do we use notifyall?
Attachment #409456 - Flags: review?(benjamin)
Since this patch is only for bug 520942, it's probably better to keep the Barrier private to that code until we need it elsewhere.
We'll want this for parallel selector matching.  David, what bug should we set this to block?
I'm going to implement the thread pool in bug 631527.
Blocks: 631527
Assignee: jones.chris.g → nobody
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: