I am trying to write a multithreaded server using io_uring
. The problem is the function 'io_uring_wait_cqe' requires calling to io_uring_cqe_seen
to mark the CQE as seen.
Therefore, in several threads, there may be a situation where the same event is handled in several threads.
Of course, I don't want to use locks, mutex, etc.
What is the best way to work with several threads?
the official suggestion from jens axboe is to prefer to use one io_uring per thread. If for some reason you really need thread synchronization an approach could be to have one worker thread that uses io_uring, and other threads use message passing to talk with the working thread.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.