CLASS INTERPRO(3)

NAME
boost::interprocess::interprocess_semaphore

SYNOPSIS

// In header: <boost/interprocess/sync/interprocess_semaphore.hpp>
class interprocess_semaphore {
public:
  // construct/copy/destruct
  interprocess_semaphore(const interprocess_semaphore &);
  interprocess_semaphore(unsigned int);
  interprocess_semaphore& operator=(const interprocess_semaphore &);
  ~interprocess_semaphore();
  // public member functions
  void post();
  void wait();
  bool try_wait();
  bool timed_wait(const boost::posix_time::ptime &);
  unspecified m_sem;  // Returns the interprocess_semaphore count.
};

DESCRIPTION

Wraps a interprocess_semaphore that can be placed in shared memory and can be shared between processes. Allows timed lock tries

  interprocess_semaphore public construct/copy/destruct

    1.

    interprocess_semaphore(const interprocess_semaphore &);
    @ //Non-copyable .RE

        2.

        interprocess_semaphore(unsigned int initialCount);

        Creates a interprocess_semaphore with the given initial count. interprocess_exception if there is an error.

        3.

        interprocess_semaphore& operator=(const interprocess_semaphore &);

        4.

        ~interprocess_semaphore();

        Destroys the interprocess_semaphore. Does not throw

  interprocess_semaphore public member functions

    1.

    void post();

    Increments the interprocess_semaphore count. If there are processes/threads blocked waiting for the interprocess_semaphore, then one of these processes will return successfully from its wait function. If there is an error an interprocess_exception exception is thrown.

    2.

    void wait();

    Decrements the interprocess_semaphore. If the interprocess_semaphore value is not greater than zero, then the calling process/thread blocks until it can decrement the counter. If there is an error an interprocess_exception exception is thrown.

    3.

    bool try_wait();

    Decrements the interprocess_semaphore if the interprocess_semaphore's value is greater than zero and returns true. If the value is not greater than zero returns false. If there is an error an interprocess_exception exception is thrown.

    4.

    bool timed_wait(const boost::posix_time::ptime & abs_time);

    Decrements the interprocess_semaphore if the interprocess_semaphore's value is greater than zero and returns true. Otherwise, waits for the interprocess_semaphore to the posted or the timeout expires. If the timeout expires, the function returns false. If the interprocess_semaphore is posted the function returns true. If there is an error throws sem_exception