42using namespace wayland;
59 registry = display_wrapper.get_registry();
70 registry.
on_global() = [&seat, ®istry](std::uint32_t name,
const std::string& interface, std::uint32_t version)
72 if(interface == seat_t::interface_name)
73 registry.
bind(name, seat, version);
77 throw std::runtime_error(
"Did NOT get seat interface - thread-safety issue!");
87 seat = seat.proxy_create_wrapper();
91 bool have_keymap =
false;
92 kbd.
on_keymap() = [&have_keymap](keyboard_keymap_format ,
int fd, std::uint32_t )
100 throw std::runtime_error(
"Did NOT get keymap - thread-safety issue!");
104 std::thread bind_thread(
bool safe)
106 return std::thread{std::bind(&binder::bind,
this, safe)};
111 binder(
const binder&) =
delete;
112 binder(binder&&) noexcept = delete;
113 ~binder() noexcept = default;
114 binder& operator=(const binder&) = delete;
115 binder& operator=(binder&&) noexcept = delete;
117 void run(
int thread_count,
int round_count,
bool safe)
119 std::atomic<bool> stop{
false};
120 std::cout <<
"Using " << thread_count <<
" threads, safe: " << safe << std::endl;
121 for(
int round = 0; round < round_count; round++)
125 std::cout <<
"Round " << round <<
"/" << round_count << std::endl;
127 std::vector<std::thread> threads;
128 threads.reserve(thread_count);
129 for(
int i = 0; i < thread_count; i++)
131 threads.emplace_back(bind_thread(safe));
133 for(
auto& thread : threads)
142int main(
int argc,
char** argv)
146 std::cerr <<
"Usage: " << argv[0] <<
" <thread count> <run count> <use safe mechanism?>" << std::endl;
150 b.run(std::stoi(argv[1]), std::stoi(argv[2]), std::stoi(argv[3]));
Represents a connection to the compositor and acts as a proxy to the display singleton object.
display_t proxy_create_wrapper()
create proxy wrapper for this display
event_queue_t create_queue() const
Create a new event queue for this display.
int roundtrip_queue(const event_queue_t &queue) const
Block until all pending request are processed by the server.
registry_t get_registry()
get global registry object
std::function< void(keyboard_keymap_format, int, uint32_t)> & on_keymap()
keyboard mapping
void set_queue(event_queue_t queue)
Assign a proxy to an event queue.
std::function< void(uint32_t, std::string, uint32_t)> & on_global()
announce global object
proxy_t bind(uint32_t name, proxy_t &interface, uint32_t version)
bind an object to the display
keyboard_t get_keyboard()
return keyboard object