Home » U++ Library support » U++ MT-multithreading and servers » Required simple MT lesson
Re: Required simple MT lesson [message #40821 is a reply to message #40819] |
Sat, 21 September 2013 17:05 |
mubeta
Messages: 77 Registered: October 2006
|
Member |
|
|
dolik.rce wrote on Sat, 21 September 2013 08:01 |
I can't compile your application (it is windows only, right?)
|
Yes.
dolik.rce wrote on Sat, 21 September 2013 08:01 |
1) Have a look at Thread::GetCount(). It does exactly the same thing as the AtomicInc/Dec(threads) in your code.
|
Developing software is not myfirst interest. Maybe I am little far from the latest U++ features.
dolik.rce wrote on Sat, 21 September 2013 08:01 |
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.
|
Yes. I am transforming this application from an more old one. The code that you see it's just the first try.
About the INTERLOCKED: How and where I must use it? For example: in case of two thread, I must use INTERLOCKED in one of them, or both?
And again, sharing variables in two thread cause a problem of data consistency when one thread change the value when the second it's reading, or there is also other problems? The shared variables must be interlocked also if the two threads are developed for read only?
dolik.rce wrote on Sat, 21 September 2013 08:01 |
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
|
I don't agree so much, but I will care. Some times a complete view it's better than many talks. In my case also better, due to this unknown language, (for me).
Thaks
[Updated on: Sat, 21 September 2013 17:07] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Thu May 09 08:09:20 CEST 2024
Total time taken to generate the page: 0.02574 seconds
|