[RESOLVED] I need thread sychronization help - Page 2
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 21 of 21

Thread: [RESOLVED] I need thread sychronization help

  1. #16
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    5,786

    Re: I need thread sychronization help

    THAT instance of WaitForMultipleObjects() will set all of the events to non-signaled
    When you create the event, you have set 'auto reset event object' - ie the system automatically resets the event to non-signalled. If you don't want this then you can create the event with manual reset - but then the event remains signalled until ResetEvent() is used to reset the event.

    Also see my posts #11, #12
    Last edited by 2kaud; October 1st, 2017 at 05:27 AM.
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++17 Compiler: Microsoft VS2017 (15.4.0)

  2. #17
    2kaud's Avatar
    2kaud is offline Super Moderator Power Poster
    Join Date
    Dec 2012
    Location
    England
    Posts
    5,786

    Re: I need thread sychronization help

    But my program is thoroughly integrated with Windows api so portability isn't even a consideration
    Have you considered using Microsoft's Parallel Containers? See https://msdn.microsoft.com/en-us/library/dd504906.aspx
    All advice is offered in good faith only. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/

    C++17 Compiler: Microsoft VS2017 (15.4.0)

  3. #18
    Join Date
    Sep 2017
    Posts
    11

    Re: I need thread sychronization help

    Quote Originally Posted by 2kaud View Post
    When you create the event, you have set 'auto reset event object' - ie the system automatically resets the event to non-signalled.
    You know, I actually tried that just before posting, but it looked like it didn't fix the problem. Turns out that I was to hasty and didn't wait for the Sleep() to finish. BUT , I tried unsetting the "auto-reset event" again and your suggestion fixed my problem: there is no more hanging.

    THANKS!


    Quote Originally Posted by 2kaud View Post
    Also see my posts #11, #12

    Oh I have WaitForMultipleObjects() wait time set to INFINITE because I don't know how to calculate the right timing. INFINITE should work unless something particularly weird happens.


    And about the thread-safe circular buffer that you suggested, I am researching it.

  4. #19
    Join Date
    Sep 2017
    Posts
    11

    Re: I need thread sychronization help

    Quote Originally Posted by 2kaud View Post
    Have you considered using Microsoft's Parallel Containers? See https://msdn.microsoft.com/en-us/library/dd504906.aspx
    No, but I think I am going to use them now that I know about them. Thanks for the guidance.

  5. #20
    Join Date
    Feb 2017
    Posts
    157

    Re: I need thread sychronization help

    Quote Originally Posted by JohnBartle View Post
    No, but I think I am going to use them now that I know about them. Thanks for the guidance.
    I know portability isn't a concern of yours but I'll mention a free and portable alternative to the Microsoft PPL (linked to by 2kaud above). It's from Intel and called TBB,

    https://www.threadingbuildingblocks.org/

    Higher level threading functionality like PPL and TBB is likely to enter standard C++ in the coming years.
    Last edited by wolle; October 4th, 2017 at 06:26 AM.

  6. #21
    Join Date
    Sep 2017
    Posts
    11

    Re: I need thread sychronization help

    Quote Originally Posted by wolle View Post
    I know portability isn't a concern of yours but I'll mention a free and portable alternative to the Microsoft PPL
    Cool, I'll have a look at it. Thanks

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This a Codeguru.com survey!


On-Demand Webinars (sponsored)