Read program_think producer consumer model

Source: Internet
Author: User

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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.