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
On torsdag den 20. December 2007, Wente, Andreas wrote:
> 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
> 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
> 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:
Thorsen Consulting ApS - Qt consulting services
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/