566 + void handle_input_event(MirInputEvent const* iev) 567 + { 568 + std::lock_guard<std::mutex> lk(mutex); 569 + if (mir_input_event_has_cookie(iev)) 570 + { 571 + auto const size = mir_input_event_get_cookie_size(iev); 572 + std::vector<uint8_t> cookie(size); 573 + 574 + mir_input_event_copy_cookie(iev, cookie.data()); 575 + out_cookies.push_back(cookie); 576 + } 577 + 578 + event_count++; 579 + } 580 + 581 + size_t get_event_count() const 582 + { 583 + std::lock_guard<std::mutex> lk(mutex); 584 + return event_count; 585 + } 586 + 587 + size_t cookie_size() const 588 + { 589 + std::lock_guard<std::mutex> lk(mutex); 590 + return out_cookies.size(); 591 + } 592 + 593 + std::vector<uint8_t> back_cookie() const 594 + { 595 + std::lock_guard<std::mutex> lk(mutex); 596 + return out_cookies.back(); 597 + } 598 + 599 + bool cookies_empty() const 600 + { 601 + std::lock_guard<std::mutex> lk(mutex); 602 + return out_cookies.empty(); 603 + }
While not blocking, this seems to be a bit of a faff for the testcase vs just directly locking the mutex when necessary :).
Otherwise, I'm OK, pending possible API changes :)
« Back to merge proposal
566 + void handle_ input_event( MirInputEvent const* iev) guard<std: :mutex> lk(mutex); event_has_ cookie( iev)) event_get_ cookie_ size(iev) ; uint8_t> cookie(size); event_copy_ cookie( iev, cookie.data()); push_back( cookie) ; guard<std: :mutex> lk(mutex); guard<std: :mutex> lk(mutex); uint8_t> back_cookie() const guard<std: :mutex> lk(mutex); guard<std: :mutex> lk(mutex); empty() ;
567 + {
568 + std::lock_
569 + if (mir_input_
570 + {
571 + auto const size = mir_input_
572 + std::vector<
573 +
574 + mir_input_
575 + out_cookies.
576 + }
577 +
578 + event_count++;
579 + }
580 +
581 + size_t get_event_count() const
582 + {
583 + std::lock_
584 + return event_count;
585 + }
586 +
587 + size_t cookie_size() const
588 + {
589 + std::lock_
590 + return out_cookies.size();
591 + }
592 +
593 + std::vector<
594 + {
595 + std::lock_
596 + return out_cookies.back();
597 + }
598 +
599 + bool cookies_empty() const
600 + {
601 + std::lock_
602 + return out_cookies.
603 + }
While not blocking, this seems to be a bit of a faff for the testcase vs just directly locking the mutex when necessary :).
Otherwise, I'm OK, pending possible API changes :)