linux pthread_suspend

后端 未结 5 2097
醉酒成梦
醉酒成梦 2021-02-08 03:36

Looks like linux doesnt implement pthread_suspend and continue, but I really need em.

I have tried cond_wait, but it is too slow. The work being threaded mostly execut

5条回答
  •  不要未来只要你来
    2021-02-08 03:46

    Have the threads block on a pipe read. Then dispatch the data through the pipe. The threads will awaken as a result of the arrival of the data they need to process. If the data is very large, just send a pointer through the pipe.

    If specific data needs to go to specific threads you need one pipe per thread. If any thread can process any data, then all threads can block on the same pipe and they will awaken round robin.

提交回复
热议问题