简短版本:我正在尝试在我的应用程序正在发送的流量上设置IP_TOS字段,即使setsockopt成功返回并且getsockopt返回正确的IP_TOS值,离开Windows 10框时,流量也未加标签。
The longer version: I have an application that sends traffic that needs to have the IP_TOS field set and the IP_TOS value can be one in a range of values; it's an environment requirement so there is no way around it. The application also needs to be cross-platform (Windows 10 and Linux). Considering those requirements, we decided to just use boost asio and set the IP_TOS on the socket when it's created.
The Linux side works the way …
我得到了一个可以归结为生产者-消费者模式的应用程序。几个线程正在做一些工作并更新单个数据集,以便更多线程可以使用该数据并使用它做自己的工作。目前,它并不是非常复杂,所有消费线程都在等待数据集,直到其中一个生产者调用一个pulseall。
现在希望有一个消费者线程在任何一组更改时从两个不同的数据集消费。团队希望将重构保持在最低限度,而我有限的线程经验让我在寻找干净的解决方案时遇到了一些问题。
快速而肮脏的解决方案是在单独的对象上进行等待和脉冲,并让消费者线程在继续之前检查其数据集中的更改。似乎没有一种方法可以让一个线程等待两个对象,而不用更强大的线程工具(线程池、任务等)替换通用线程,除非我没有找到正确的东西。