get semaphore count

This is a discussion on get semaphore count within the Windows Programming forums, part of the Platform Specific Boards category; I want to get the count of a semaphore without tripping the signaled/non-signaled state. But no matter what I can ...

  1. #1
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    1,690

    get semaphore count

    I want to get the count of a semaphore without tripping the signaled/non-signaled state. But no matter what I can think of, I'd have to do it at one point or another. How can I accomplish this regardless of the maximum value and current value?
    A class that doesn't overload all operators just isn't finished yet. -- SmugCeePlusPlusWeenie
    A year spent in artificial intelligence is enough to make one believe in God. -- Alan J. Perlis

  2. #2
    Chinese pâté foxman's Avatar
    Join Date
    Jul 2007
    Location
    Canada
    Posts
    404
    Well, what about managing the semaphore objects inside a class ? I don't know if there's a direct way to get to the count of the semaphore (except with the ReleaseSemaphore function but in this case it's not a valid option), but depending on how you use the semaphore object, it might be a valid option. Or it might not.
    I hate real numbers.

  3. #3
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    1,690
    I've thought of that, but the whole idea is that my API can handle semaphores created and managed by other programs by use of Win32 API. If I use a class, it'll screw everything up.
    A class that doesn't overload all operators just isn't finished yet. -- SmugCeePlusPlusWeenie
    A year spent in artificial intelligence is enough to make one believe in God. -- Alan J. Perlis

  4. #4
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,701
    Even if there were a "GetSemCount()" function, the returned count would only be a *snapshot* at the point in time the function was called.

    So what would you do with that information? Why do you need it?

    gg

  5. #5
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,598
    Windows takes care of the semaphore count and functionality. You just use it.

  6. #6
    Unregistered User Yarin's Avatar
    Join Date
    Jul 2007
    Posts
    1,690
    Yeah... the more I think about it, the more I realize my original idea is in vain. Thanks for replying anyhow.
    A class that doesn't overload all operators just isn't finished yet. -- SmugCeePlusPlusWeenie
    A year spent in artificial intelligence is enough to make one believe in God. -- Alan J. Perlis

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. bintree and count (withouth using template)?
    By cubimongoloid in forum C++ Programming
    Replies: 7
    Last Post: 05-24-2009, 07:22 AM
  2. input question
    By piyush_v in forum C Programming
    Replies: 9
    Last Post: 04-12-2007, 08:09 AM
  3. Semaphore Question
    By azamsharp1 in forum C Programming
    Replies: 4
    Last Post: 10-30-2005, 09:01 AM
  4. CreateSemaphore/ReleaseSemaphore
    By nrieger in forum Windows Programming
    Replies: 2
    Last Post: 08-03-2005, 07:57 AM
  5. Program Crashing
    By Pressure in forum C Programming
    Replies: 3
    Last Post: 04-18-2005, 11:28 PM

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