For a non-static member operation of a class, it is straightforward to make it guarded by setting its concurrency property. I know that it is a mutex object which is actually a member attribute introduced to the class.
Then, what is the easy way for static members ?
I want to be able to serialize the access to a static member of a class ? Should I introduce static mutex attributes to the class by myself ?
Özgür Eser Akdemir
Pinned topic guarding the static member attribute of a class
Answered question This question has been answered.
Unanswered question This question has not been answered yet.
Updated on 2013-01-10T16:12:13Z at 2013-01-10T16:12:13Z by shanz9903
Yevo 270002F6T8292 Posts
Re: guarding the static member attribute of a class2011-08-20T20:21:06ZThis is the accepted answer. This is the accepted answer.Yes, you should directly define a static mutex (OMProtected) attribute and use it in static operation. See implementation of OMDECLARE_GUARDED and GUARD_OPERATION macros for more details.
Actually , you can define some OMDECLARE_STATIC_GUARDED macro, which is similar to OMDECLARE_GUARDED, but use static guard. Then you can define a type in your class, which is declared as OMDECLARE_STATIC_GUARDED, and use the GUARD_OPERATION inside of static member.
shanz9903 270003S6R4335 Posts
Re: guarding the static member attribute of a class2013-01-10T16:12:13ZThis is the accepted answer. This is the accepted answer.
- Yevo 270002F6T8
This didn't work for me.
I ended up having to call the new name of the property OMDECLARE_GUARDED_STATIC since calling it anything other than OMDECLARE_GUARDED_xxx doesn't get generated in the code.
This seems like a Code Gen bug to me.