Search found 374 matches

by mael15
Tue Apr 30, 2019 7:47 pm
Forum: C++ Development
Topic: closing wxProgressDialog with a wxThread
Replies: 51
Views: 1235

Re: closing wxProgressDialog with a wxThread

You need a "barrier" class, which wxWidgets does not have. If you use Boost, you can take it from there. Otherwise i found this: https://stackoverflow.com/a/27118537 looks good! kind of a combination of all three :) BTW: Can you explain in words why a worker thread needs to spawn 3 other threads? I...
by mael15
Tue Apr 30, 2019 5:42 pm
Forum: C++ Development
Topic: closing wxProgressDialog with a wxThread
Replies: 51
Views: 1235

Re: closing wxProgressDialog with a wxThread

Okay, so I have created two pools of workers, now I have a problem with synchronization: a worker thread from pool A creates 3 jobs for worker threads in pool B. Which technique makes thread A wait until all 3 Bs are finished without using Sleep and checking a counter again and again?! I made a mini...
by mael15
Mon Apr 29, 2019 12:36 pm
Forum: C++ Development
Topic: unhandled unknown exception in wxThreadInternal::DoThreadStart
Replies: 24
Views: 621

Re: unhandled unknown exception in wxThreadInternal::DoThreadStart

alys666 wrote:
Mon Apr 29, 2019 12:14 pm
at certain conditions. get rid of this 3 threads, or use second stage Boss.
Okay, I will. That is a lot of work but I guess it will be worth it.
Thanx everyone!
by mael15
Mon Apr 29, 2019 12:07 pm
Forum: C++ Development
Topic: unhandled unknown exception in wxThreadInternal::DoThreadStart
Replies: 24
Views: 621

Re: unhandled unknown exception in wxThreadInternal::DoThreadStart

Yes, this could be a solution like DoubleMax also suggested. I hesitate because that would mean that one thread pool "open files" would use another pool "fill buffer", the buffer being filled with the content of the files. That sounds dangerous, but maybe it is necessary. You can always use only on...
by mael15
Mon Apr 29, 2019 11:33 am
Forum: C++ Development
Topic: unhandled unknown exception in wxThreadInternal::DoThreadStart
Replies: 24
Views: 621

Re: unhandled unknown exception in wxThreadInternal::DoThreadStart

if you swear that you have an exception in TlsSetValue, it could have only one reason - you exceeded number of threads, existing in your app at this moment. If you are sure that this is the only possible explanation, then I will have to work with a fixed number of threads and rewrite a lot of code.
by mael15
Mon Apr 29, 2019 11:29 am
Forum: C++ Development
Topic: unhandled unknown exception in wxThreadInternal::DoThreadStart
Replies: 24
Views: 621

Re: unhandled unknown exception in wxThreadInternal::DoThreadStart

Why worker thread just don't get next task where it finish previous instead of creating a new thread for each task? I mean create so-called thread pool. Yes, this could be a solution like DoubleMax also suggested. I hesitate because that would mean that one thread pool "open files" would use anothe...
by mael15
Mon Apr 29, 2019 10:50 am
Forum: C++ Development
Topic: unhandled unknown exception in wxThreadInternal::DoThreadStart
Replies: 24
Views: 621

Re: unhandled unknown exception in wxThreadInternal::DoThreadStart

Do you mean a limit of threads existing at the same time or a limit how many can be created in a certain time window? I had the suspicion that there was a bug in wxWidgets that allowed only a total number of threads to be created during the lifetime of a program. But in the meantime i tested it and...
by mael15
Mon Apr 29, 2019 10:35 am
Forum: C++ Development
Topic: unhandled unknown exception in wxThreadInternal::DoThreadStart
Replies: 24
Views: 621

Re: unhandled unknown exception in wxThreadInternal::DoThreadStart

I try to answer as good as possible. -how you create and destroy this 3 additional threads per worker? do this temporary threads really exit? When these hundreds of jobs have finished I sometimes find 2 of 8 "open file" threads (using wxMessageQueue) "stuck" with this exception. In this case, each t...
by mael15
Mon Apr 29, 2019 9:52 am
Forum: C++ Development
Topic: unhandled unknown exception in wxThreadInternal::DoThreadStart
Replies: 24
Views: 621

Re: unhandled unknown exception in wxThreadInternal::DoThreadStart

Can you easily implement a counter that counts them? Not easily, I use threads in different scenarios. But these exceptions happen at very different times so I guess that makes a problem with a total limit unlikely? Do you mean a limit of threads existing at the same time or a limit how many can be...
by mael15
Mon Apr 29, 2019 8:32 am
Forum: C++ Development
Topic: unhandled unknown exception in wxThreadInternal::DoThreadStart
Replies: 24
Views: 621

Re: unhandled unknown exception in wxThreadInternal::DoThreadStart

Are you maybe creating and destroying lots of threads all the time? If yes, i would change this. It's better to have a small thread pool (depending on the number of available cores) and let them all just wait for jobs which are distributed through a job queue. (see wxMessageQueue, it's very simple ...
by mael15
Fri Apr 26, 2019 2:49 pm
Forum: C++ Development
Topic: closing wxProgressDialog with a wxThread
Replies: 51
Views: 1235

Re: closing wxProgressDialog with a wxThread

Yes, I agree. As suggested by DoubleMax in a previous post, I now have copied the wxMessageQueue and added a simple getter that returns m_queue.size() so the whole m_job_count is gone now.
But I will try to think about the sequence in future thread stuff!
by mael15
Fri Apr 26, 2019 1:39 pm
Forum: C++ Development
Topic: closing wxProgressDialog with a wxThread
Replies: 51
Views: 1235

Re: closing wxProgressDialog with a wxThread

i m just continuing critics of your code :) to make it perfect :) see comments in the code void Boss::start() { int cpuCount = wxThread::GetCPUCount(); //< if your threads could wait something, kinda i/o operations(disk, network, etc), you could increase number of threads, for better performance, b...
by mael15
Fri Apr 26, 2019 1:00 pm
Forum: C++ Development
Topic: closing wxProgressDialog with a wxThread
Replies: 51
Views: 1235

Re: closing wxProgressDialog with a wxThread

okay, it works fine now. I simply forgot to reset _job_count und _stopAll before the second run. No more heap errors, shows progress, is abortable, all good. Here is the code if someone needs the same functionality in the future, I use it as a template in my app: #include <wx/msgqueue.h> #include <w...
by mael15
Fri Apr 26, 2019 12:43 pm
Forum: C++ Development
Topic: closing wxProgressDialog with a wxThread
Replies: 51
Views: 1235

Re: closing wxProgressDialog with a wxThread

i cannot just now check all your code. but have a question. why do you store workers in vector? boss just creates N workers and forgets about them. workers are waiting on queue and are checking boss's exit_flag. workers are detached threads(wxThread by default. if i remember). and they will be auto...
by mael15
Fri Apr 26, 2019 12:39 pm
Forum: C++ Development
Topic: closing wxProgressDialog with a wxThread
Replies: 51
Views: 1235

Re: closing wxProgressDialog with a wxThread

As there is a new wxGenericProgressDialog created each time, i don't see how it can be at fault. Are you sure the rest of the code behaves as expected? Please confirm that the first process is 100% complete, and that the code has exited the event handler. Did you take measures to avoid reentrancy? ...