CComMultiThreadModelNoCS

This is a discussion on CComMultiThreadModelNoCS within the Windows Programming forums, part of the Platform Specific Boards category; Hello everyone, I read the code for class CComMultiThreadModelNoCS of ATL. What means, -------------------- (Section Threading Model Support, Chapter 3 ...

  1. #1
    Registered User
    Join Date
    May 2006
    Posts
    1,579

    CComMultiThreadModelNoCS

    Hello everyone,


    I read the code for class CComMultiThreadModelNoCS of ATL. What means,

    --------------------
    (Section Threading Model Support, Chapter 3 Objects in ATL, ATL Internals)
    CComMultiThreadModelNoCS is designed for multi-threaded objects the eschew object-level locking in favor of a more fine-grained scehme?
    --------------------

    My understanding is the object designed could use other approaches other than critical section, like mutex/event to do synchronization. Not sure whether my understanding is correct?


    thanks in advance,
    George

  2. #2
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,296
    I haven't used that class myself, but it sounds like one might simply use it with a number of seperate critical sections that each guard specific member variables in the class. Or perhaps if a different lock type is desired such as a spin lock.

    I possibly could have used this recently when I needed seperate locks around certain individual variables.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  3. #3
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Thanks iMalc,


    I can understand your sample of spinlock. But I do not know what do you mean "separate critical sections", do you mean not using object level one single lock (such as using this pointer as lock)? I think even if using CComMultiThreadModelNoCS, one can use multiple CComMultiThreadModel object inside a class to create multiple locks flexibly without using CComMultiThreadModelNoCS.

    Could you help to clarify please?

    Quote Originally Posted by iMalc View Post
    I haven't used that class myself, but it sounds like one might simply use it with a number of seperate critical sections that each guard specific member variables in the class. Or perhaps if a different lock type is desired such as a spin lock.

    I possibly could have used this recently when I needed seperate locks around certain individual variables.

    regards,
    George

  4. #4
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,296
    Quote Originally Posted by George2 View Post
    But I do not know what do you mean "separate critical sections", do you mean not using object level one single lock (such as using this pointer as lock)?
    Yeah.
    I think even if using CComMultiThreadModelNoCS, one can use multiple CComMultiThreadModel object inside a class to create multiple locks flexibly without using CComMultiThreadModelNoCS.
    I've recently declared extra CComAutoCriticalSections in a class. I get the feeling CComMultiThreadModel is not designed to be used via aggregation, though there may well be no problem with that. I basically agree with your assessment though.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  5. #5
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Thanks iMalc,


    Quote Originally Posted by iMalc View Post
    I get the feeling CComMultiThreadModel is not designed to be used via aggregation, though there may well be no problem with that.
    Why do you think "CComMultiThreadModel is not designed to be used via aggregation", show me a sample or some pseudo code please?


    regards,
    George

  6. #6
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,296
    I'm just basing my assumption on the name of the class, and how other similiar classes are used. I've never actually tried using it that way, but as I mentioned, it quite possibly will technically work. It would just most likely be rather confusing to anyone else reading the code. That's really all I have to say about it.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  7. #7
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Thanks iMalc,


    You mean you just think that "CComMultiThreadModel is not designed to be used via aggregation", but never tried it before? :-)

    Sorry, my English is not good. :-)

    Quote Originally Posted by iMalc View Post
    I'm just basing my assumption on the name of the class, and how other similiar classes are used. I've never actually tried using it that way, but as I mentioned, it quite possibly will technically work. It would just most likely be rather confusing to anyone else reading the code. That's really all I have to say about it.

    regards,
    George

  8. #8
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,296
    Yeah, I think so.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  9. #9
    Registered User
    Join Date
    May 2006
    Posts
    1,579
    Thanks all the same, iMalc!


    Quote Originally Posted by iMalc View Post
    Yeah, I think so.

    regards,
    George

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21