Mir

Code review comment for lp:~mir-team/mir/public-cookie-api

Revision history for this message
Chris Halse Rogers (raof) wrote :

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 :)

review: Approve

« Back to merge proposal