Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-24 Thread Alan Ezust
On Wed, Oct 24, 2012 at 1:08 AM, d3fault wrote: > On 10/23/12, Alan Ezust wrote: > > > > http://www.ics.com/designpatterns is one place where you can see the > book's > > contents and download the code examples. It requires you to > register/login > > but it's free. > > > > Which example are you

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-24 Thread d3fault
On 10/23/12, Alan Ezust wrote: > > http://www.ics.com/designpatterns is one place where you can see the book's > contents and download the code examples. It requires you to register/login > but it's free. > Which example are you referring to? Life or PrimeThreads? I read the whole chapter on QThr

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-24 Thread Bo Thorsen
Den 23-10-2012 22:28, d3fault skrev: > On 10/22/12, Bo Thorsen wrote: >> Now I'm getting annoyed. You're the one spreading misinformation here. I >> mentioned the pure computation as one of the cases where I prefer >> subclassing. But that of course doesn't mean you can't do it in other ways. > Yo

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-23 Thread Alan Ezust
On Tue, Oct 23, 2012 at 6:51 PM, d3fault wrote: > > > > Regarding rewriting the example, I think the best way to rewrite it is to > > remove all usage of QThread entirely, and see if you can figure out how > to > > program it using the higher-level QtConcurrent API. In my book [Intro to > > Desi

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-23 Thread Francisco Gonzalez
2012/10/24 d3fault : > > Weird, so what you're saying is: > > QWidget 'this' parent > _Layout > _Layout1Widget1 > _Layout1Widget2 > __SubLayout1 // added via Layout.addLayout(), Layout now being his parent > _SubLayout1Widget1 > _SubLayout1Widget2 > __SubLayout2 // ditto > _SubLayout2Wiget1 > ___Su

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-23 Thread d3fault
On 10/23/12, Alan Ezust wrote: > Actually, it's not as simple as I stated. Basically, adding a widget to a > layout > makes it the child of the widget that it is a layout for. So if you add a > widget to a sub-layout, > it actually won't be the sibling of that layout object, but an uncle or > some

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-23 Thread Alan Ezust
Actually, it's not as simple as I stated. Basically, adding a widget to a layout makes it the child of the widget that it is a layout for. So if you add a widget to a sub-layout, it actually won't be the sibling of that layout object, but an uncle or something. On Tue, Oct 23, 2012 at 1:28 PM, d3

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-23 Thread Giuseppe D'Angelo
On 23 October 2012 20:24, Thiago Macieira wrote: > > 1) volatile wasn't designed for threading. > > It was designed for memory-mapped I/O Going slightly off topic, I never managed to find reliable sources about which problem volatile was meant to solve when it was *first* introduced: MMIO, changi

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-23 Thread Thiago Macieira
On terça-feira, 23 de outubro de 2012 23.58.41, Sergey Borovkov wrote: > I did some googling and found this > http://lists.qt.nokia.com/pipermail/qt4-feedback/2009-October/000880.html - > you are saying that it's ok to use volatile on x86_64 here since there is > no actual synchronization here. Or

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-23 Thread d3fault
Quick fix: On 10/23/12, d3fault wrote: > emit readyForConnections(&obj); //Would be dangerous to call methods > etc on this object. Should only connect to it's signals/slots What I meant to say is that listeners to that signal should not call methods on the object. Calling methods on the o

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-23 Thread d3fault
Thank you Alan, I've fixed the comment to say sibling. On 10/22/12, Bo Thorsen wrote: > Now I'm getting annoyed. You're the one spreading misinformation here. I > mentioned the pure computation as one of the cases where I prefer > subclassing. But that of course doesn't mean you can't do it in o

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-23 Thread Sergey Borovkov
I did some googling and found this http://lists.qt.nokia.com/pipermail/qt4-feedback/2009-October/000880.html - you are saying that it's ok to use volatile on x86_64 here since there is no actual synchronization here. Or am I missing something here and cases are different? Sorry for nitpicking, I am

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-23 Thread Thiago Macieira
On terça-feira, 23 de outubro de 2012 12.14.37, Till Oliver Knoll wrote: > - Use "QAtomicInt" instead of a "volatile bool" (for the simple "Stop > thread" use case) or The problems with volatile bool: 1) volatile wasn't designed for threading. It was designed for memory-mapped I/O. Its purpose i

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-23 Thread Alan Ezust
Comment from one of the files in that .zip file: >When we call this->setLayout(m_Layout), 'this' becomes the parent of > m_Layout and all child objects (everything we add to the layout becomes a > child of m_Layout), and deletes it (and all children) for us when 'this' is destroyed Not exactly tr

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-23 Thread Till Oliver Knoll
2012/10/23 Graeme Gill : > Till Oliver Knoll wrote: >> As Bo pointed out on "ordinary desktops" you are probably lucky, since >> the Intel desktop architecture (single CPU, multiple cores) apparently >> have "coherent caches". > > I doubt there is any luck involved. Coherent memory architectures >

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-23 Thread Graeme Gill
Till Oliver Knoll wrote: > As Bo pointed out on "ordinary desktops" you are probably lucky, since > the Intel desktop architecture (single CPU, multiple cores) apparently > have "coherent caches". I doubt there is any luck involved. Coherent memory architectures are the simplest and least error pr

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-23 Thread Till Oliver Knoll
2012/10/23 Harri Pasanen : > On 10/23/2012 12:14 PM, Till Oliver Knoll wrote: >> As Bo pointed out on "ordinary desktops" you are probably lucky, since >> the Intel desktop architecture (single CPU, multiple cores) apparently >> have "coherent caches". > > Just a note that things like out-of-order

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-23 Thread Harri Pasanen
On 10/23/2012 12:14 PM, Till Oliver Knoll wrote: > As Bo pointed out on "ordinary desktops" you are probably lucky, since > the Intel desktop architecture (single CPU, multiple cores) apparently > have "coherent caches". Just a note that things like out-of-order execution and threading behave sub

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-23 Thread Till Oliver Knoll
2012/10/23 Till Oliver Knoll : > 2012/10/23 Thomas McGuire : >... But off > course the CPU will (might) still cache it into 1st or 2nd level > cache. Uh... oh.. never mind my terminology here (1st and 2nd level cache - might be wrong), but as always Wikipedia is a good starting point for understan

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-23 Thread Till Oliver Knoll
2012/10/23 Thomas McGuire : > > ... > If you share data between threads, you need to protected them by a mutex or > use aquire/release barriers manually. A mutex has implicit aquire/release > semantics. THAT'S exactly the point I was missing here! Thanks for the excellent clarification! I wasn't a

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-23 Thread Thomas McGuire
Hi, On Monday 22 October 2012 22:44:05 Till Oliver Knoll wrote: > Am 22.10.2012 um 16:07 schrieb Jan Kundrát : > > On 10/22/12 14:12, Till Oliver Knoll wrote: > >> So the net effect is that the "worker thread" does "one loop too much" > >> - but /eventually/ it will see that m_continue has been se

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-22 Thread Bo Thorsen
Den 23-10-2012 06:50, d3fault skrev: > OT'ish (relative to above): someone mentioned in reply to me that > implementing QThread's run() method is needed for the pure computation > use case. This is simply not true, please stop spreading misinformation. Now I'm getting annoyed. You're the one spr

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-22 Thread d3fault
re: this whole thread I'm not sure it's fact, but what I've come to... err... believe... is that while yes, Qt does provide low level primitives for synchronizing threads, you should not have to use them! Basically if you think you do, you should instead change your application's design (for those

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-22 Thread Till Oliver Knoll
Am 22.10.2012 um 16:07 schrieb Jan Kundrát : > On 10/22/12 14:12, Till Oliver Knoll wrote: >> So the net effect is that the "worker thread" does "one loop too much" >> - but /eventually/ it will see that m_continue has been set to 'false' >> and will terminate. And that is exactly what we want and

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-22 Thread Bo Thorsen
Den 22-10-2012 15:51, Jan Kundrát skrev: > On 10/22/12 14:16, Bo Thorsen wrote: >> Not correct. Neither the compiler nor the CPU can reorder around a volatile. > Hi Bo, > various sources which I've read about this topic (like [1], [2], [3], > [4]) disagree. I might be wrong and would like to be cor

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-22 Thread Jan Kundrát
On 10/22/12 14:12, Till Oliver Knoll wrote: > So the net effect is that the "worker thread" does "one loop too much" > - but /eventually/ it will see that m_continue has been set to 'false' > and will terminate. And that is exactly what we want and hence "good > enough" (no need for protecting the

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-22 Thread Jan Kundrát
On 10/22/12 14:16, Bo Thorsen wrote: > Not correct. Neither the compiler nor the CPU can reorder around a volatile. Hi Bo, various sources which I've read about this topic (like [1], [2], [3], [4]) disagree. I might be wrong and would like to be corrected in that case -- references are welcome.

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-22 Thread Syam Krishnan
On 10/22/2012 10:57 AM, Bo Thorsen wrote: Den 22-10-2012 03:38, Syam Krishnan skrev: A question to all: I have a GUI application. I need to do some task (for example, periodically readin

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-22 Thread Bo Thorsen
@qt-project.org [mailto:interest-bounces+daniel.price=fxhome@qt-project.org] *On Behalf Of *Bo Thorsen *Sent:* 22 October 2012 06:40 *To:* interest@qt-project.org *Subject:* Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends Den 21-10-2012 23:46, d3fa

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-22 Thread Bo Thorsen
Den 22-10-2012 12:10, Jan Kundrát skrev: > On 10/22/12 07:21, d3fault wrote: >> volatile bools work > I wasn't able to find a context for this, but in general, this is not > true. In general, no. For all x86 and x86-64 processors, it is true. Ints and bools have atomic reads and writes on th

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-22 Thread Till Oliver Knoll
2012/10/22 Jan Kundrát : > On 10/22/12 07:21, d3fault wrote: >> volatile bools work > > I wasn't able to find a context for this, but in general, this is not > true. Declaring a variable volatile does *not* make it suitable to be > used as a synchronization primitive across threads. In Academi

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-22 Thread Daniel Price
>Could you elaborate? One of the reasons I prefer QThread is that the >SIGNAL/SLOT provides a thread-safe signalling/communication bridge across >threads. There is that. I've not had a case in my own code however where I needed that. I use invokables (std::function or boost::function) for cal

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-22 Thread Charley Bay
Daniel spaketh: > You should look into the active object design pattern. The idea is that you > hide the object that lives in another thread behind a managing object. I > only discovered this recently and it’s vastly superior to subclassing > QThread, or using moveToThread or any of that rubbish.

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-22 Thread Daniel Price
: interest@qt-project.org Subject: Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends Den 21-10-2012 23:46, d3fault skrev: On Oct 21, 2012 11:02 AM, "Bo Thorsen" mailto:b...@fioniasoftware.dk>> wrote: > > If you set out to correct the document

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-22 Thread Jan Kundrát
On 10/22/12 07:21, d3fault wrote: > volatile bools work I wasn't able to find a context for this, but in general, this is not true. Declaring a variable volatile does *not* make it suitable to be used as a synchronization primitive across threads. As a side effect, it might also make the co

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-21 Thread Till Oliver Knoll
Am 22.10.2012 um 07:21 schrieb d3fault : >> ...If you only need to read from the serial port periodically, you can set >> your backend up like I did for backend2 in the exampe... which also uses a >> timer. >> If that implies getting rid of a 2nd "polling thread" entirely then that's something

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-21 Thread Bo Thorsen
Den 21-10-2012 23:46, d3fault skrev: On Oct 21, 2012 11:02 AM, "Bo Thorsen" > wrote: > > If you set out to correct the documentation, you should make it better, > not go from one one-sided way of thinking to another. > What? Are we talking about the same thing? 9

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-21 Thread Bo Thorsen
Den 22-10-2012 03:38, Syam Krishnan skrev: On 10/22/2012 03:16 AM, d3fault wrote: On Oct 21, 2012 11:02 AM, "Bo Thorsen" > wrote: > > If you set out to correct the documentation, you should make it better, > not go from one one-sided way of thinking to another. >

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-21 Thread d3fault
guh sorry wrong list mfw 2012 and we still have to change that On Oct 21, 2012 10:20 PM, "d3fault" wrote: > volatile bools work, but just know that every time you check it you are > doing a non-cached memory read (relatively slow). It can't read from the > cache/registers (much faster) because ot

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-21 Thread Syam Krishnan
On 10/22/2012 03:16 AM, d3fault wrote: On Oct 21, 2012 11:02 AM, "Bo Thorsen" wrote: > > If you set out to correct the documentation, you should make it better, > not go from one one-sided way of thinking to

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-21 Thread d3fault
On Oct 21, 2012 11:02 AM, "Bo Thorsen" wrote: > > If you set out to correct the documentation, you should make it better, > not go from one one-sided way of thinking to another. > What? Are we talking about the same thing? 99% of the time, implementing QThread and overriding run() is not what the

Re: [Interest] Heavily Commented Example: Simple Single Frontend with Two Backends

2012-10-21 Thread Bo Thorsen
Den 21-10-2012 09:16, d3fault skrev: > 1) To be a good starting/reference point for Qt beginners. I'm trying > to combat the misinformation on how to use QThreads that the outdated > docs have embedded into so many brains. There's nothing wrong with doing that, but it would be even better to subm