41 using namespace wayland;
58 registry = display_wrapper.get_registry();
69 registry.
on_global() = [&seat, ®istry](std::uint32_t name, 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 format,
int fd, std::uint32_t size)
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)};
109 void run(
int thread_count,
int round_count,
bool safe)
111 std::atomic<bool> stop{
false};
112 std::cout <<
"Using " << thread_count <<
" threads, safe: " << safe << std::endl;
113 for(
int round = 0; round < round_count; round++)
117 std::cout <<
"Round " << round <<
"/" << round_count << std::endl;
119 std::vector<std::thread> threads;
120 threads.reserve(thread_count);
121 for(
int i = 0; i < thread_count; i++)
123 threads.emplace_back(bind_thread(safe));
125 for(
auto& thread : threads)
134 int main(
int argc,
char** argv)
138 std::cerr <<
"Usage: " << argv[0] <<
" <thread count> <run count> <use safe mechanism?>" << std::endl;
142 b.run(std::stoi(argv[1]), std::stoi(argv[2]), std::stoi(argv[3]));