A search tool developed by an individual, because it has not been designed and ready-made before, but needs to be used internally, so it has made a cottage version without design, after reading the program_think blog post, I suddenly remembered that I had a preference for design, so I would like to summarize it accordingly.
Link:
First, declare that the buffer can adopt a queue buffer, a circular buffer, or two queue buffers (the synchronization and deadlock overhead if multithreading is used ).
The buffer can be used as a member of the buffer class, and there are producer and consumer objects in it. The producer saves the output data to the buffer.
Queue buffer. When the queue size reaches a certain level, the consumer object starts to process data, pop out the queue data, and then process the data. Note that if
Production and Consumption use two threads, so be sure to pay attention to the synchronization and deadlock control used in the buffer zone.
The most important thing to improve for individual search tools is to reduce coupling between classes. Well, let's talk about it first.
You can also see this article at http://my.oschina.net/shawnchen/blog/13052.