[Interest] QEventLoop ::hasPendingEvents() replacement?

Jason H jhihn at gmx.com
Wed Jun 26 16:16:02 CEST 2019


Can't you use a QRunnable / QThreadPool with maxThreadCount=1?


> Sent: Wednesday, June 26, 2019 at 1:58 AM
> From: "Fabrice Mousset | GEOCEPT GmbH" <fabrice.mousset at geocept.com>
> To: "Thiago Macieira" <thiago.macieira at intel.com>, "interest at qt-project.org" <interest at qt-project.org>
> Subject: Re: [Interest] QEventLoop ::hasPendingEvents() replacement?
>
> Hi Thiago,
> 
> thank's a lot for you answer and for your explanation.
> Sadly for me, replacing with true/false is not an alternative for my use case.
> I will have to rework the whole process.
> I have a worker class (with his own thread), and before allowing a new task to be started I have to be sure previous task has been finished.
> Depending on the type of task there are more or less slots which are triggered and depending on the parameter each slots could also trigger another slots.
> hasPendingEvents() was a very attractive solution for my use case, too bad for me!
> 
> Fabrice Mousset
> 
> > -----Urspr√ľngliche Nachricht-----
> > Von: Interest <interest-bounces at qt-project.org> Im Auftrag von Thiago
> > Macieira
> > Gesendet: Dienstag, 25. Juni 2019 18:09
> > An: interest at qt-project.org
> > Betreff: Re: [Interest] QEventLoop ::hasPendingEvents() replacement?
> > 
> > On Tuesday, 25 June 2019 08:00:02 PDT Fabrice Mousset | GEOCEPT GmbH
> > wrote:
> > > Hi all,
> > >
> > > Since Qt 5.3 QAbstractEventDispatcher::hasPendingEvents() has been set
> > > "obsolete". Is there an alternate way to know if a QEventLoop has
> > > pending events?
> > 
> > The reason it's obsolete is that it's a race condition. Since the race can't be
> > fixed, there will be no replacement.
> > 
> > I suggest you replace the call with "true" or "false", depending on how your
> > code around it would react to an event being posted by another thread at
> > just the wrong moment.
> > 
> > --
> > Thiago Macieira - thiago.macieira (AT) intel.com
> >   Software Architect - Intel System Software Products
> > 
> 
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> https://lists.qt-project.org/listinfo/interest
>


More information about the Interest mailing list