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

ACE_Select_Reactor_Token_T< ACE_SELECT_REACTOR_MUTEX > Class Template Reference

Used as a synchronization mechanism to coordinate concurrent access to a Select_Reactor object. More...

#include <Select_Reactor_T.h>

Inheritance diagram for ACE_Select_Reactor_Token_T< ACE_SELECT_REACTOR_MUTEX >:

Inheritance graph
[legend]
Collaboration diagram for ACE_Select_Reactor_Token_T< ACE_SELECT_REACTOR_MUTEX >:

Collaboration graph
[legend]
List of all members.

Public Methods

 ACE_Select_Reactor_Token_T (ACE_Select_Reactor_Impl &r, int s_queue=ACE_SELECT_TOKEN::FIFO)
 ACE_Select_Reactor_Token_T (int s_queue=ACE_SELECT_TOKEN::FIFO)
virtual ~ACE_Select_Reactor_Token_T (void)
virtual void sleep_hook (void)
 Called just before the ACE_Event_Handler goes to sleep.

ACE_Select_Reactor_Implselect_reactor (void)
 Get the select_reactor implementation.

void select_reactor (ACE_Select_Reactor_Impl &)
 Set the select_reactor implementation.

virtual void dump (void) const
 Dump the state of an object.


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.


Private Attributes

ACE_Select_Reactor_Implselect_reactor_

Detailed Description

template<class ACE_SELECT_REACTOR_MUTEX>
class ACE_Select_Reactor_Token_T< ACE_SELECT_REACTOR_MUTEX >

Used as a synchronization mechanism to coordinate concurrent access to a Select_Reactor object.

This class is used to make the <ACE_Select_Reactor> thread-safe. By default, the thread that runs the <handle_events> loop holds the token, even when it is blocked in the <select> call. Whenever another thread wants to access the <ACE_Reactor> via its <register_handler>, <remove_handler>, etc. methods) it must ask the token owner for temporary release of the token. To accomplish this, the owner of a token must define a <sleep_hook> through which it can be notified to temporarily release the token if the current situation permits this. The owner of the token is responsible for deciding which request for the token can be granted. By using the <ACE_Token::renew> API, the thread that releases the token temporarily can specify to get the token back right after the other thread has completed using the token. Thus, there is a dedicated thread that owns the token ``by default.'' This thread grants other threads access to the token by ensuring that whenever somebody else has finished using the token the ``default owner'' first holds the token again, i.e., the owner has the chance to schedule other threads. The thread that most likely needs the token most of the time is the thread running the dispatch loop. Typically the token gets released prior to entering the <select> call and gets ``re-acquired'' as soon as the <select> call returns, which results probably in many calls to <release>/<acquire> that are not really needed since no other thread would need the token in the meantime. That's why the dispatcher thread is chosen to be the owner of the token. In case the token would have been released while in <select> there would be a good chance that the <fd_set> could have been modified while the <select> returns from blocking and trying to re-acquire the lock. Through the token mechanism it is ensured that while another thread is holding the token, the dispatcher thread is blocked in the <renew> call and not in <select>. Thus, it is not critical to change the <fd_set>. The implementation of the <sleep_hook> mechanism provided by the <ACE_Select_Reactor_Token> enables the default owner to be the thread that executes the dispatch loop.


Constructor & Destructor Documentation

template<class ACE_SELECT_REACTOR_MUTEX>
ACE_Select_Reactor_Token_T< ACE_SELECT_REACTOR_MUTEX >::ACE_Select_Reactor_Token_T ACE_Select_Reactor_Impl   r,
int    s_queue = ACE_SELECT_TOKEN::FIFO
 

template<class ACE_SELECT_REACTOR_MUTEX>
ACE_Select_Reactor_Token_T< ACE_SELECT_REACTOR_MUTEX >::ACE_Select_Reactor_Token_T int    s_queue = ACE_SELECT_TOKEN::FIFO
 

template<class ACE_SELECT_REACTOR_MUTEX>
ACE_Select_Reactor_Token_T< ACE_SELECT_REACTOR_MUTEX >::~ACE_Select_Reactor_Token_T void    [virtual]
 


Member Function Documentation

template<class ACE_SELECT_REACTOR_MUTEX>
void ACE_Select_Reactor_Token_T< ACE_SELECT_REACTOR_MUTEX >::dump void    const [virtual]
 

Dump the state of an object.

template<class ACE_SELECT_REACTOR_MUTEX>
void ACE_Select_Reactor_Token_T< ACE_SELECT_REACTOR_MUTEX >::select_reactor ACE_Select_Reactor_Impl  
 

Set the select_reactor implementation.

template<class ACE_SELECT_REACTOR_MUTEX>
ACE_Select_Reactor_Impl & ACE_Select_Reactor_Token_T< ACE_SELECT_REACTOR_MUTEX >::select_reactor void   
 

Get the select_reactor implementation.

template<class ACE_SELECT_REACTOR_MUTEX>
void ACE_Select_Reactor_Token_T< ACE_SELECT_REACTOR_MUTEX >::sleep_hook void    [virtual]
 

Called just before the ACE_Event_Handler goes to sleep.


Member Data Documentation

template<class ACE_SELECT_REACTOR_MUTEX>
ACE_Select_Reactor_Token_T< ACE_SELECT_REACTOR_MUTEX >::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

template<class ACE_SELECT_REACTOR_MUTEX>
ACE_Select_Reactor_Impl* ACE_Select_Reactor_Token_T< ACE_SELECT_REACTOR_MUTEX >::select_reactor_ [private]
 


The documentation for this class was generated from the following files:
Generated on Wed Jan 14 22:47:39 2004 for ACE by doxygen1.2.18