qt-interest@trolltech.com
[Top] [All Lists]

Re: How to yield execution to main messageloop?

Subject: Re: How to yield execution to main messageloop?
From: Bo Thorsen
Date: Thu, 20 Dec 2007 14:55:11 +0100
You have a standard mutual exclusion problem here. You can't use the Qt 
classes for this, since they work inside a single application space. I did 
consider using a placement new on QMutex inside the shared memory space, but 
I don't know if this would work, so I assume not.

The problem is solved several times in computer science. The one I have tried 
implementing before was Lamports solution. I found the article about this one 
here: http://research.microsoft.com/users/lamport/pubs/fast-mutex.ps.

Bo.

On torsdag den 20. December 2007, Wente, Andreas wrote:
> Hello,
>
> I am developing a small logging component which consists of two parts. A
> small application, the logreciever, which reads a shared memory with log
> messages and a small class which can be put in any qt-app that should do
> logging.
>
> when there are many log entries it could be happen, that the shared memory
> is full. so the logger class has to wait until the logreciever application
> has processed all log entries. Since I have no Qthread in the logger class
> I have no uSleep or something like this. the only thing I found was
> QObject::thread()->wait(). But this doesn't work.
>
> while (buffer->nextPosition == MESSAGE_LIST_SIZE)
> {
>       // Messagelist full
>       sm_logout.unlock();
>       thread()->wait(100);   // will not wait and throws a warning
> QThread::wait: Thread tried to wait on itself sm_logout.lock();
> }
>
> So how can I make my function to yield executen to the Application
> Messageloop for a number of ms?
>
> --
> Mit freundlichen Grüßen / kind regards,
>
> Andreas Wente
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body. List archive and information:
> http://lists.trolltech.com/qt-interest/



-- 

Thorsen Consulting ApS - Qt consulting services
http://www.thorsen-consulting.dk

--
To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
"unsubscribe" in the subject or the body.
List archive and information: http://lists.trolltech.com/qt-interest/

<Prev in Thread] Current Thread [Next in Thread>