Waiting on multiple events C++

前端 未结 4 552
后悔当初
后悔当初 2021-02-10 05:37

Is there a recommended way to wait on multiple inputs. For example I would like my program to be able to receive input from 3 sources:

Listen on a thread condition e.g.

4条回答
  •  一向
    一向 (楼主)
    2021-02-10 06:28

    It certainly seems as though these three different messaging options are mutually exclusive for a single thread; how can a single thread read from stdin while it's waiting for a thread condition?

    If you really don't want to spawn three threads, the only option I can fathom is somehow modifying or parameterizing the thread, stream, and socket libraries to take a reference to a synchronization object.

提交回复
热议问题