Pipe-and-Filter Architecture for txt file.

Hi everyone,

I hope you are all fine and live happy and safely. This is the first time to post here in the forum, and I feel that there is a nice and variety developers community here. I really appreciate and willing to share with you some of my experience and knowledge. By the way, my English is second language, so if you misunderstand me please let me know.

Currently, I am working in designing and implementing a Filter-and-Pipe architecture for Word document. I stuck with implementing the pipe class. My classes looks like;

Class A: read a txt file line by line and SEND it to Class B.
Class B: read the line coming from A, processing it and SEND it to Class C.
Class C: read the line coming from B, processing it and SEND it to Class D.
Class D: read the line coming from C, processing it and print it out.

each of these classes should run in its own thread. Each Filter should wait if there is no data ready. once it ready, should the sender notify the receiver.

I have implement the classes and stuck with the pipe. I don't know how to send the processed line to the next Filter.

When I run the project, I notice that the Class D run and stop before it gets all data to print it out. This is because of the class D check if the queue is empty. If True, it will stop processing and stop the thread.

For example, the txt file has 10 line. Class D will stop after line 4 because the Class C takes time to process line 3 and can not pass data to the queue for class D.

I hope you understand the issue. I need your help if you have any idea.