Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
2 replies Latest Post - ‏2013-01-10T16:12:13Z by shanz9903
oeakdemir
oeakdemir
144 Posts
ACCEPTED ANSWER

Pinned topic guarding the static member attribute of a class

‏2011-08-18T17:31:10Z |
Hi all,

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
Ankara, Turkey
Updated on 2013-01-10T16:12:13Z at 2013-01-10T16:12:13Z by shanz9903
  • Yevo
    Yevo
    278 Posts
    ACCEPTED ANSWER

    Re: guarding the static member attribute of a class

    ‏2011-08-20T20:21:06Z  in response to oeakdemir
    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
      shanz9903
      268 Posts
      ACCEPTED ANSWER

      Re: guarding the static member attribute of a class

      ‏2013-01-10T16:12:13Z  in response to Yevo
      yevo,

      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.