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 » Required simple MT lesson
Re: Required simple MT lesson [message #40819 is a reply to message #40818] Sat, 21 September 2013 14:01 Go to previous messageGo to previous message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

Hi mubeta,

I can't compile your application (it is windows only, right?), but I noticed few things that are thread related. They might not cause your trouble, but you asked for a lesson so I tell you anyway Smile

1) Have a look at Thread::GetCount(). It does exactly the same thing as the AtomicInc/Dec(threads) in your code.

2) You are accessing iniKeys Vector from various threads without any serialization. This might cause trouble when CommLoop modifies it's content while GetUpdates reads from it or vice versa. You should use INTERLOCKED or INTERLOCKED_ macros (or some other mechanism) to ensure no two threads access the variable at the same time. Note that this might cause some slowdown or even deadlocks, so one has to be careful about what is accessed from where.

3) Not really a code issue, but when posting example code on the forum 5000 lines of code is quite a lot Smile It would be great if you could try to create a smaller testcase that exhibits the problem next time Wink

Best regards,
Honza
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: TcpSocket: send data from server to client
Next Topic: INTERLOCK and Mutex object
Goto Forum:
  


Current Time: Thu May 09 11:17:54 CEST 2024

Total time taken to generate the page: 0.02747 seconds