简体   繁体   English

FIFO线程

[英]Threads with fifo

I have the application below where thread 1 reads from a file and put to FIFO, then thread 2 reads that FIFO and process the data and send to network socket, thread 3 is receiving data from network socket and then save the result to file2 but sometimes the received data has to be re-processed by thread2, so the question is what's the best thing to do? 我在下面的应用程序中,线程1从文件读取并放入FIFO,然后线程2读取FIFO并处理数据并发送到网络套接字,线程3从网络套接字接收数据,然后将结果保存到file2,但有时接收到的数据必须由thread2重新处理,所以问题是最好的方法是什么? Do I need to send to FIFO again? 我是否需要再次发送到FIFO? or have another fifo between thread 3 and thread 2? 还是在线程3和线程2之间有另一个fifo? or neither ? 还是都不?

File1 --> thread 1 --> FIFO --> thread 2 --> network socket File1->线程1-> FIFO->线程2->网络套接字

network socket --> thread 3 --> file2 网络套接字->线程3-> file2

BTW, the above is a sample of what I have, the actual program will have many threads read from FIFO and send to the network, not sure if using FIFO this way will cause latency or will be a bottleneck. 顺便说一句,以上是我所拥有的示例,实际程序将有许多线程从FIFO读取并发送到网络,不确定使用FIFO是否会导致延迟或成为瓶颈。

Appreciate you help. 感谢您的帮助。

Ummm, 嗯,

Is there a particular reason why select system call which will monitor an array of file and socket descriptors is not being used? 为什么没有使用选择系统调用来监视文件和套接字描述符数组的特定原因? This could simplify the code as shown here . 这可以简化代码所示这里

Are you using pthreads or something like boost thread library... 您正在使用pthread还是boost线程库之类的东西...

Are these threads indeed different processes... or is this all one program where you use pthread_cond_wait() ? 这些线程确实是不同的进程吗?还是使用pthread_cond_wait()的所有程序?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM