wxThread: Windows vs *nix

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

wxThread: Windows vs *nix

Post by ONEEYEMAN »

Hi, ALL,

Code: Select all

wxThread::ExistCode MyThread::Entry()
{
    while( !TestDestroy() )
     {
         std::lock_guard<std::mutex> loocker();
         int res = call_some_func();
         if( res )
             Delete();
     }
     return (wxThread::ExitCode) 0;
}
When I run this code on Windows (8.1/MSVC 2017) everything works as expected - thread ends successfully.
When I run it on Linux (GTK 3.24, C++11) - it does not. Thread does not ends.

Am I doing something wrong here?

Thank you.
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxThread: Windows vs *nix

Post by doublemax »

Calling Delete() from inside the thread itself is definitely unusual. Remove it (just use break) and check if it makes any difference.
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxThread: Windows vs *nix

Post by ONEEYEMAN »

doublemax,
Yes it worked.
But now - where do I kill the thread? Or it will just die and all I will need is to delete the pointer?

Thank you.
User avatar
doublemax
Moderator
Moderator
Posts: 19103
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: wxThread: Windows vs *nix

Post by doublemax »

Detached threads delete themselves when they're done.
Use the source, Luke!
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7449
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: wxThread: Windows vs *nix

Post by ONEEYEMAN »

doublemax,
I followed the code from wxThread docs and it looks like everything works. I'll try linux/mac today, but suspect everything will work there as well.

Thank you.
Post Reply