Good day!

Advise books on the topic accordingly. In the variety of search engines you can get lost and you want to hear the advice of experienced people that read the novice and understand as deeply as possible in the subject. Desirable in order of increasing complexity for the study.

Started with this C ++ Concurrency in Action

PS at the moment there is a task: a common queue of tasks, several streams put them there, and several read and execute accordingly. In general, it seems to fit into the pattern of Poducer-Consumer.

Closed due to the fact that it is necessary to reformulate the question so that it was possible to give an objectively correct answer by the participants of Oceinic , sepgg , ermak0ff , PashaPash , Vladimir Glinskikh 18 Oct '15 at 10:35 .

The question gives rise to endless debates and discussions based not on knowledge, but on opinions. To get an answer, rephrase your question so that it can be given an unambiguously correct answer, or delete the question altogether. If the question can be reformulated according to the rules set out in the certificate , edit it .

3 answers 3

The aforementioned book focuses on the practical aspect of multithreading. Begin to dive into the topic better with her. On it you can and finish. For most real-world tasks this will be enough. If you want to know the multithreading to the full depth and become a master, then you cannot do without studying the theory. For this there is another book - "Parallel and Distributed Programming Using C ++ . " Description on does not correspond to the content. It looks frivolous and in no way scary. You would think this book is for beginners. In fact, it is an academic hardcore, which is very difficult to read.

As for the Producer-Consumer pattern specifically, its implementation is best done in a lock-free manner. In the magazine Dr. Dobb's was an article on how to do this . True, in your case, you still need some kind of blocking. It will be necessary to block separately Producer's and separate Consumer's so that more than one stream of each type does not climb at a time.

  • Yes, a very cool book. But very good. - skegg

Well, I don’t know about parallelism, but concurrency is such a guru Doug Lea . The link is his books. I even saw his site with source codes / examples and so on.

    @ Fe1iX , which is better to read, I do not know.

    And for the task, do not bother, make it easier.

    If in * nix, use pthread_mutex_t ( pthread_mutex_lock()/pthread_mutex_unlock() from pthread.h) to share access, and sem_t ( sem_wait()/sem_post() from semaphore.h) to manage the queue

    • In principle, the initial implementation is done this way. But I want to better understand the topic. - Fe1iX
    • @ Fe1iX, all I've come across lately is either chewing on the obvious, or some theoretical problems. You can search for sources in the network. I remember once saw beautiful, but I do not remember where. - avp