S3FC project page S3FC home page

Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

s3_subscribable_fifo Class Reference

A helper class that implements the consumer and producer subscription and notification. More...

#include <s3_fifo_base.h>

Inheritance diagram for s3_subscribable_fifo:

Inheritance graph
[legend]
Collaboration diagram for s3_subscribable_fifo:

Collaboration graph
[legend]
List of all members.

Public Methods

void subscribe_producer (const s3_semaphore &sem)
 Subscribe a producer and use the supplied semaphore to indicate a state change. More...

void unsubscribe_producer (const s3_semaphore &sem)
 Unsubscribe a producer from the producer notification list. More...

bool is_subscribed_producer (const s3_semaphore &sem)
 Test if the semaphore is already subscribed. More...

void subscribe_consumer (const s3_semaphore &sem)
 Subscribe a consumer and use the supplied semaphore to indicate a state change. More...

void unsubscribe_consumer (const s3_semaphore &sem)
 Unsubscribe a consumer from the consumer notification list. More...

bool is_subscribed_consumer (const s3_semaphore &sem)
 Test if the semaphore is already subscribed. More...

void notify_producers () const
 Notify all producers of a state change by post() 'ing on all the semaphores in the producer list. More...

void notify_consumers () const
 Notify all consumers of a state change by post() 'ing on all the semaphores in the producer list. More...


Protected Attributes

std::list< s3_semaphore * > producers
 List of subscribed producers. More...

std::list< s3_semaphore * > consumers
 List of subscribed consumers. More...

s3_mutex notification_lock
 Mutex protecting the notification mechanism. More...


Private Types

typedef std::list< s3_semaphore
* >::const_iterator 
T_ConstIterator
typedef std::list< s3_semaphore
* >::const_iterator 
T_Iterator

Detailed Description

A helper class that implements the consumer and producer subscription and notification.

Definition at line 46 of file s3_fifo_base.h.


Member Typedef Documentation

typedef std::list<s3_semaphore*>::const_iterator s3_subscribable_fifo::T_ConstIterator [private]
 

Definition at line 48 of file s3_fifo_base.h.

Referenced by notify_consumers, and notify_producers.

typedef std::list<s3_semaphore*>::const_iterator s3_subscribable_fifo::T_Iterator [private]
 

Definition at line 49 of file s3_fifo_base.h.


Member Function Documentation

bool s3_subscribable_fifo::is_subscribed_consumer const s3_semaphore   sem
 

Test if the semaphore is already subscribed.

Returns:
true if subscribed, false otherwise

Definition at line 132 of file s3_fifo_base.cc.

References consumers, s3_mutex::lock, notification_lock, and s3_mutex::unlock.

bool s3_subscribable_fifo::is_subscribed_producer const s3_semaphore   sem
 

Test if the semaphore is already subscribed.

Returns:
true if subscribed, false otherwise

Definition at line 81 of file s3_fifo_base.cc.

References s3_mutex::lock, notification_lock, producers, and s3_mutex::unlock.

void s3_subscribable_fifo::notify_consumers   const
 

Notify all consumers of a state change by post() 'ing on all the semaphores in the producer list.

Definition at line 157 of file s3_fifo_base.cc.

References consumers, s3_mutex::lock, notification_lock, T_ConstIterator, and s3_mutex::unlock.

Referenced by s3_spsc_fifo_queue::close_input, s3_fifo_queue< s3_txport_data< s3_message > >::close_input, and s3_growable_fifo_queue< s3_txport_event >::push.

void s3_subscribable_fifo::notify_producers   const
 

Notify all producers of a state change by post() 'ing on all the semaphores in the producer list.

Definition at line 144 of file s3_fifo_base.cc.

References s3_mutex::lock, notification_lock, producers, T_ConstIterator, and s3_mutex::unlock.

Referenced by s3_spsc_fifo_queue::close_output, s3_fifo_queue< s3_txport_data< s3_message > >::close_output, and s3_growable_fifo_queue< s3_txport_event >::pop.

void s3_subscribable_fifo::subscribe_consumer const s3_semaphore   sem
 

Subscribe a consumer and use the supplied semaphore to indicate a state change.

A pointer to the supplied semaphore is stored and the caller should ensure that it stays valid for the existence of the queue. This fails, by throwing an s3_generic_exception, if the specified semaphore is already subscribed as a consumer.

Parameters:
sem  Semaphore used to signal the consumer.
Precondition:
subscribe_consumer(sem) has not been called before.

Definition at line 92 of file s3_fifo_base.cc.

References consumers, s3_mutex::lock, notification_lock, and s3_mutex::unlock.

Referenced by s3_post_office::main_loop.

void s3_subscribable_fifo::subscribe_producer const s3_semaphore   sem
 

Subscribe a producer and use the supplied semaphore to indicate a state change.

A pointer to the supplied semaphore is stored and the caller should ensure that it stays valid for the existence of the queue. This fails, by throwing an s3_generic_exception, if the specified semaphore is already subscribed as a producer.

Parameters:
sem  Semaphore used to signal the producer.
Precondition:
subscribe_producer(sem) has not been called before.

Definition at line 40 of file s3_fifo_base.cc.

References s3_mutex::lock, notification_lock, producers, and s3_mutex::unlock.

void s3_subscribable_fifo::unsubscribe_consumer const s3_semaphore   sem
 

Unsubscribe a consumer from the consumer notification list.

This fails, by throwing an s3_generic_exception, if the specified semaphore is not subscribed as a consumer.

Parameters:
sem  Semaphore used to signal the consumer.
Precondition:
subscribe_consumer(sem) has been called before.

Definition at line 112 of file s3_fifo_base.cc.

References consumers, s3_mutex::lock, notification_lock, and s3_mutex::unlock.

void s3_subscribable_fifo::unsubscribe_producer const s3_semaphore   sem
 

Unsubscribe a producer from the producer notification list.

This fails, by throwing an s3_generic_exception, if the specified semaphore is not subscribed as a producer.

Parameters:
sem  Semaphore used to signal the producer.
Precondition:
subscribe_producer(sem) has been called before.

Definition at line 60 of file s3_fifo_base.cc.

References s3_mutex::lock, notification_lock, producers, and s3_mutex::unlock.


Member Data Documentation

std::list<s3_semaphore*> s3_subscribable_fifo::consumers [protected]
 

List of subscribed consumers.

Definition at line 58 of file s3_fifo_base.h.

Referenced by is_subscribed_consumer, notify_consumers, subscribe_consumer, and unsubscribe_consumer.

s3_mutex s3_subscribable_fifo::notification_lock [protected]
 

Mutex protecting the notification mechanism.

Definition at line 62 of file s3_fifo_base.h.

Referenced by is_subscribed_consumer, is_subscribed_producer, notify_consumers, notify_producers, subscribe_consumer, subscribe_producer, unsubscribe_consumer, and unsubscribe_producer.

std::list<s3_semaphore*> s3_subscribable_fifo::producers [protected]
 

List of subscribed producers.

Definition at line 54 of file s3_fifo_base.h.

Referenced by is_subscribed_producer, notify_producers, subscribe_producer, and unsubscribe_producer.


The documentation for this class was generated from the following files:
Send comments to: s3fc@stonethree.com SourceForge Logo