Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ MT-multithreading and servers » bug in CoWork since C++11
Re: bug in CoWork since C++11 [message #46797 is a reply to message #46796] Tue, 09 August 2016 11:43 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 13980
Registered: November 2005
Ultimate Member
crydev wrote on Tue, 09 August 2016 11:36
mirek wrote on Tue, 09 August 2016 11:15
Well, the one possible explanation is that your CoWork is global (or static) variable. Is that so?


My CoWork instance is not a global variable. It is a variable as member of a class and it is not a pointer. It is a singleton class, though. I construct it with a private constructor and a GetInstance method.

class X
{
private:
     CoWork mThreadPool;
     X();
public:
     static X* GetInstance()
     {
          static X instance;
          return &instance;
     };
}


I see. It is static then.

I believe what happens here is that first, CoWork instance is constructed. Then you schedule the work, which creates global static thread pool. On app exit, pool is therefore destructed BEFORE destructor of CoWork, which would normally performed the remaining work (by calling Finish).

Can you try to call GetInstance()->Finish() at the end of APP_MAIN to prove this hypothesis? (if true, I will then start thinking if resolving this situation is worth the trouble or rather mentioning in docs...

Mirek
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: how many threads should i use in SkyLark server?
Next Topic: WebSockets non blocking mode?
Goto Forum:
  


Current Time: Wed May 15 04:03:29 CEST 2024

Total time taken to generate the page: 0.02522 seconds