Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #80359
| From | "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: good reference on threads |
| Date | 2021-06-12 14:41 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <sa39m8$mkk$1@dont-email.me> (permalink) |
| References | <s9u208$94h$2@dont-email.me> <cf233b93-519a-4987-ae48-7831b2d55179n@googlegroups.com> <s9uee1$bk0$1@dont-email.me> <s9vfug$rd8$1@dont-email.me> |
On 6/11/2021 4:03 AM, Paavo Helde wrote: > 11.06.2021 04:31 Lynn McGuire kirjutas: >> >> I want multiple threads to share the massive dataset that we use. >> Very tricky, I have tried sharing data between the threads and it was >> a disaster. > > MFC is not thread-safe, so only the main thread can call any MFC functions. > > For data exchange the most robust way is to use a couple of message > queues for passing events back and forth between the threads. Any data > which is not MT-safe to access should be copied by value into a new > non-shared object when putting into the queue. > > One can easily build such a queue with a std::queue and a std::mutex. > > For example, if a background queue wants to display a message to the > user, it can send an event to the main thread queue containing the > message. The main thread would check in a MFC OnIdle() function if there > are any events in the queue, and process them in the main thread. > Oh I missed the MFC usage. Actually used it a couple of times in the early to mid 90's. Hummm, well, for a multi_producer-to-single_consumer relationship, if one can get over a LIFO order, this construction might be of use to the OP: https://groups.google.com/g/comp.lang.c++/c/1gppAtQpIQk/m/XX8-VDoMBgAJ One can also reverse the LIFO to get a FIFO.
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
good reference on threads Lynn McGuire <lynnmcguire5@gmail.com> - 2021-06-10 16:59 -0500
Re: good reference on threads Öö Tiib <ootiib@hot.ee> - 2021-06-10 15:49 -0700
Re: good reference on threads Öö Tiib <ootiib@hot.ee> - 2021-06-10 17:58 -0700
Re: good reference on threads Lynn McGuire <lynnmcguire5@gmail.com> - 2021-06-10 20:31 -0500
Re: good reference on threads Öö Tiib <ootiib@hot.ee> - 2021-06-10 20:31 -0700
Re: good reference on threads "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-06-10 21:32 -0700
Re: good reference on threads "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-06-10 21:33 -0700
Re: good reference on threads Ian Collins <ian-news@hotmail.com> - 2021-06-11 20:17 +1200
Re: good reference on threads Lynn McGuire <lynnmcguire5@gmail.com> - 2021-06-11 14:13 -0500
Re: good reference on threads Paavo Helde <myfirstname@osa.pri.ee> - 2021-06-11 14:03 +0300
Re: good reference on threads Paavo Helde <myfirstname@osa.pri.ee> - 2021-06-11 15:19 +0300
Re: good reference on threads "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-06-12 14:41 -0700
Re: good reference on threads Lynn McGuire <lynnmcguire5@gmail.com> - 2021-06-10 22:03 -0500
Re: good reference on threads "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-06-10 20:08 -0700
Re: good reference on threads Lynn McGuire <lynnmcguire5@gmail.com> - 2021-07-01 22:27 -0500
Re: good reference on threads "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com> - 2021-07-01 21:28 -0700
Re: good reference on threads legalize+jeeves@mail.xmission.com (Richard) - 2021-07-27 01:21 +0000
Re: good reference on threads Cholo Lennon <chololennon@hotmail.com> - 2021-06-12 23:06 -0300
Re: good reference on threads Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-06-12 21:47 -0700
Re: good reference on threads Keith Thompson <Keith.S.Thompson+u@gmail.com> - 2021-06-12 21:49 -0700
Re: good reference on threads legalize+jeeves@mail.xmission.com (Richard) - 2021-07-27 01:19 +0000
Re: good reference on threads Bonita Montero <Bonita.Montero@gmail.com> - 2021-07-27 03:58 +0200
csiph-web