parallel processing - Shared memory C++ and Win API 32 with custom class -
are there samples getting custom class including large arrays properties in shared memory? need read/write access different threads in same process. size of class instance unknown @ compilation time. openmp solutions not allowed in case, win 32 api or native c++ features.
you not need shared memory this. memory in 1 c++ process implicitly shared , accessible threads, far know address.
what need synchronization threads access objects in proper order (without race condition). objects should implement so-called monitor pattern.
in c++ manually this
- put (win32 api) mutex member of object
- lock mutex in beginning of every method
- unlock @ method exit. it's better use locker object on stack deal exceptions.
(in languages declare methods or objects synchronized, in c++ manually)
alternatively use higher level parallel pattern, 'readers/writers'. prefer message passing
Comments
Post a Comment