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 |
|
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
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 It would be great if you could try to create a smaller testcase that exhibits the problem next time
Best regards,
Honza
|
|
|
Goto Forum:
Current Time: Thu May 09 11:17:54 CEST 2024
Total time taken to generate the page: 0.02747 seconds
|