Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, May 2008
Use QThread and QMutex


Message 1 in thread

Hi,
I'm using threads and semaphores in my applications but i have some
problems while stopping the application and manage the resources. I don
use any kind of GUI,  the application is a library (.so), it is called
from other applications. It is necessary to use QApplication or other
king of manager to manage the threads and semaphores?

Thank you in advance for your support,
Gonçalo

--
 [ signature omitted ] 

Message 2 in thread

Hi,

What kind of problems exactly? Can you be more specific?

Using a manager will depends on the complexity of your collection of
threads and semaphores.

Qt 4.4 provides QThreadPool which manage QThreads, so it's worth to try it.

Regards,

Jesse

On Wed, May 14, 2008 at 6:03 PM, GonÃalo Monteiro <icognitus@xxxxxxxxx> wrote:
> Hi,
> I'm using threads and semaphores in my applications but i have some
> problems while stopping the application and manage the resources. I don
> use any kind of GUI,  the application is a library (.so), it is called
> from other applications. It is necessary to use QApplication or other
> king of manager to manage the threads and semaphores?
>
> Thank you in advance for your support,
> GonÃalo
>
> --
> 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/
>
>

Message 3 in thread

Okay,

If you call wait() when the thread is terminating, eventually the
thread would be terminated. But it depends on what kind of codes
you're executing on that thread (run() function). There's several
cases which could make the thread unable to finish or took a very long
time to finish, that explains why your application blocks, or you get
the "QThread object
destroyed while thread is still running" -> meaning the thread is still running.

Probably you should check your code, when you exit the thread.

About the semaphores, maybe you haven't released the resources when
you delete the semaphore objects.

Once again, check your code for possible bugs.

Regards,

Jesse

On Thu, May 15, 2008 at 12:32 AM, GonÃalo Monteiro <icognitus@xxxxxxxxx> wrote:
> When i give an order to thread stop the processing the function "run()"
> reach the end but application  blocks on the "wait()"  wainting  for the
> thread stops. If i use "wait(5000)" i receive the message: QThread object
> destroyed while thread is still running.
> In the semaphores (mutex) i have a problem when i delete them. I receive the
> message: Mutex destroy failure: Device or resource busy.
> By the way, i  have Qt3...
> Thanks in advance,
> GonÃalo
>
> Jesse Armand wrote:
>
> Hi,
>
> What kind of problems exactly? Can you be more specific?
>
> Using a manager will depends on the complexity of your collection of
> threads and semaphores.
>
> Qt 4.4 provides QThreadPool which manage QThreads, so it's worth to try it.
>
> Regards,
>
> Jesse
>
> On Wed, May 14, 2008 at 6:03 PM, GonÃalo Monteiro <icognitus@xxxxxxxxx>
> wrote:
>
>
> Hi,
> I'm using threads and semaphores in my applications but i have some
> problems while stopping the application and manage the resources. I don
> use any kind of GUI,  the application is a library (.so), it is called
> from other applications. It is necessary to use QApplication or other
> king of manager to manage the threads and semaphores?
>
> Thank you in advance for your support,
> GonÃalo
>
> --
> 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/
>
>
>
>
> NïïïïïrïïzÇuïïï[hïØïïÞïÞçïï[^r (ï ïïïì ï&Þ{azËïï-ïïayï
> ÈïïïÜ+ïjwbïï+ïïbïxmïïïï+-ïïï[^r (ïï{^ïï-/===

Message 4 in thread

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
  <title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi!<br>
<br>
Jesse Armand wrote:
<blockquote
 cite="mid45d629ef0805142117n7275a90dxb950b6b757329265@xxxxxxxxxxxxxx"
 type="cite">
  <pre wrap="">Okay,

If you call wait() when the thread is terminating, eventually the
thread would be terminated. But it depends on what kind of codes
you're executing on that thread (run() function). There's several
cases which could make the thread unable to finish or took a very long
time to finish, that explains why your application blocks, or you get
the "QThread object
destroyed while thread is still running" -&gt; meaning the thread is still running.
  </pre>
</blockquote>
Yes, you are right. But i have a qDebug at the end of the run()
function and it is printed, this way the run() function reaches the
end... Am i right or i missing some thing?<br>
<blockquote
 cite="mid45d629ef0805142117n7275a90dxb950b6b757329265@xxxxxxxxxxxxxx"
 type="cite">
  <pre wrap="">
Probably you should check your code, when you exit the thread.

About the semaphores, maybe you haven't released the resources when
you delete the semaphore objects.

Once again, check your code for possible bugs.

Regards,

Jesse
  </pre>
</blockquote>
Thanks,<br>
GonÃalo<br>
<br>
<blockquote
 cite="mid45d629ef0805142117n7275a90dxb950b6b757329265@xxxxxxxxxxxxxx"
 type="cite">
  <pre wrap="">
On Thu, May 15, 2008 at 12:32 AM, GonÃalo Monteiro <a class="moz-txt-link-rfc2396E" href="mailto:icognitus@xxxxxxxxx";>&lt;icognitus@xxxxxxxxx&gt;</a> wrote:
  </pre>
  <blockquote type="cite">
    <pre wrap="">When i give an order to thread stop the processing the function "run()"
reach the end but application  blocks on the "wait()"  wainting  for the
thread stops. If i use "wait(5000)" i receive the message: QThread object
destroyed while thread is still running.
In the semaphores (mutex) i have a problem when i delete them. I receive the
message: Mutex destroy failure: Device or resource busy.
By the way, i  have Qt3...
Thanks in advance,
GonÃalo

Jesse Armand wrote:

Hi,

What kind of problems exactly? Can you be more specific?

Using a manager will depends on the complexity of your collection of
threads and semaphores.

Qt 4.4 provides QThreadPool which manage QThreads, so it's worth to try it.

Regards,

Jesse

On Wed, May 14, 2008 at 6:03 PM, GonÃalo Monteiro <a class="moz-txt-link-rfc2396E" href="mailto:icognitus@xxxxxxxxx";>&lt;icognitus@xxxxxxxxx&gt;</a>
wrote:


Hi,
I'm using threads and semaphores in my applications but i have some
problems while stopping the application and manage the resources. I don
use any kind of GUI,  the application is a library (.so), it is called
from other applications. It is necessary to use QApplication or other
king of manager to manage the threads and semaphores?

Thank you in advance for your support,
GonÃalo

--
 [ signature omitted ] 

Message 5 in thread

Check for the existence of signal finished() or check the return of
isFinished() call.

If the thread has finished by checking this, then I don't know what's
your problem, if I can't see your code.

On Thu, May 15, 2008 at 5:39 PM, GonÃalo Monteiro <icognitus@xxxxxxxxx> wrote:
> Hi!
>
> Yes, you are right. But i have a qDebug at the end of the run() function and
> it is printed, this way the run() function reaches the end... Am i right or
> i missing some thing?
>