41using namespace wayland;
58 registry = display_wrapper.get_registry();
69 registry.
on_global() = [&seat, ®istry](std::uint32_t name,
const std::string& interface, std::uint32_t version)
71 if(interface == seat_t::interface_name)
72 registry.
bind(name, seat, version);
76 throw std::runtime_error(
"Did NOT get seat interface - thread-safety issue!");
86 seat = seat.proxy_create_wrapper();
90 bool have_keymap =
false;
91 kbd.
on_keymap() = [&have_keymap](keyboard_keymap_format ,
int fd, std::uint32_t )
99 throw std::runtime_error(
"Did NOT get keymap - thread-safety issue!");
103 std::thread bind_thread(
bool safe)
105 return std::thread{std::bind(&binder::bind,
this, safe)};
110 binder(
const binder&) =
delete;
111 binder(binder&&) noexcept = delete;
112 ~binder() noexcept = default;
113 binder& operator=(const binder&) = delete;
114 binder& operator=(binder&&) noexcept = delete;
116 void run(
int thread_count,
int round_count,
bool safe)
118 std::atomic<bool> stop{
false};
119 std::cout <<
"Using " << thread_count <<
" threads, safe: " << safe << std::endl;
120 for(
int round = 0; round < round_count; round++)
124 std::cout <<
"Round " << round <<
"/" << round_count << std::endl;
126 std::vector<std::thread> threads;
127 threads.reserve(thread_count);
128 for(
int i = 0; i < thread_count; i++)
130 threads.emplace_back(bind_thread(safe));
132 for(
auto& thread : threads)
141int main(
int argc,
char** argv)
145 std::cerr <<
"Usage: " << argv[0] <<
" <thread count> <run count> <use safe mechanism?>" << std::endl;
149 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