File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -1460,11 +1460,13 @@ class PTHREAD_EXTERN bound_queue_t :public world_stop_notifier_t {
1460
1460
size_t bound;
1461
1461
void notify_world_stop() override;
1462
1462
void wait();
1463
+ void wait_no_world_stop_check(); // used by async system
1463
1464
public:
1464
1465
void *lame_opaque; // has to be public for the scanner to find it
1465
1466
bound_queue_t(thread_control_base_t *tc_, size_t);
1466
1467
~bound_queue_t();
1467
1468
void enqueue(void*);
1469
+ void enqueue_no_world_stop_check(void*); // used by async system
1468
1470
void* dequeue();
1469
1471
void* maybe_dequeue();
1470
1472
void resize(size_t);
@@ -1524,6 +1526,11 @@ void bound_queue_t::wait() {
1524
1526
//fprintf(stderr, "possible size change in queue detected %p\n", this);
1525
1527
}
1526
1528
1529
+ void bound_queue_t::wait_no_world_stop_check() {
1530
+ size_changed.wait_for(member_lock, ::std::chrono::duration<int>(1)); // 1second
1531
+ }
1532
+
1533
+
1527
1534
// get the number of element in the queue
1528
1535
// (NOT the bound!)
1529
1536
size_t bound_queue_t::len() {
@@ -1545,6 +1552,16 @@ bound_queue_t::enqueue(void* elt)
1545
1552
size_changed.notify_all(); // cannot return an error
1546
1553
}
1547
1554
1555
+ void
1556
+ bound_queue_t::enqueue_no_world_stop_check(void* elt)
1557
+ {
1558
+ ::std::unique_lock< ::std::mutex> l(member_lock);
1559
+ while(ELTQ->size() >= bound) wait_no_world_stop_check(); // guard against spurious wakeups!
1560
+ ELTQ->push_back(elt);
1561
+ size_changed.notify_all(); // cannot return an error
1562
+ }
1563
+
1564
+
1548
1565
void*
1549
1566
bound_queue_t::dequeue()
1550
1567
{
You can’t perform that action at this time.
0 commit comments