#include <TP_Reactor.h>
Collaboration diagram for ACE_TP_Token_Guard:

Public Methods | |
| ACE_TP_Token_Guard (ACE_Select_Reactor_Token &token) | |
| Constructor that will grab the token for us. More... | |
| ~ACE_TP_Token_Guard (void) | |
| Destructor. This will release the token if it hasnt been released till this point. More... | |
| void | release_token (void) |
| Release the token .. More... | |
| int | is_owner (void) |
| Returns whether the thread that created this object ownes the token or not. More... | |
| int | grab_token (ACE_Time_Value *max_wait_time=0) |
| A helper method that grabs the token for us, after which the thread that owns that can do some actual work. More... | |
| int | acquire_token (ACE_Time_Value *max_wait_time=0) |
Private Methods | |
| ACE_TP_Token_Guard (void) | |
Private Attributes | |
| ACE_Select_Reactor_Token & | token_ |
| The Select Reactor token. More... | |
| int | owner_ |
| Flag that indicate whether the thread that created this object owns the token or not. A value of 0 indicates that this class hasnt got the token (and hence the thread) and a value of 1 vice-versa. More... | |
In short, this class will be owned by one thread by creating on the stack. This class gives the status of the ownership of the token and manages the ownership
Definition at line 86 of file TP_Reactor.h.
|
|
Constructor that will grab the token for us.
Definition at line 51 of file TP_Reactor.i.
|
|
|
Destructor. This will release the token if it hasnt been released till this point.
Definition at line 59 of file TP_Reactor.i. References ACE_MT, and owner_.
|
|
|
|
|
|
A helper method that grabs the token for us, after which the thread that owns that can do some actual work. This differs from grab_token () as it uses acquire () to get the token instead of acquire_read () Definition at line 61 of file TP_Reactor.cpp. References ACE_MT, ACE_TRACE, ETIME, ACE_OS::gettimeofday, and owner_. Referenced by ACE_TP_Reactor::handle_socket_events, and ACE_TP_Reactor::remove_handler.
00062 {
00063 ACE_TRACE ("ACE_TP_Token_Guard::acquire_token");
00064
00065 // Try to grab the lock. If someone if already there, don't wake
00066 // them up, just queue up in the thread pool.
00067 int result = 0;
00068
00069 if (max_wait_time)
00070 {
00071 ACE_Time_Value tv = ACE_OS::gettimeofday ();
00072 tv += *max_wait_time;
00073
00074 ACE_MT (result = this->token_.acquire (0,
00075 0,
00076 &tv));
00077 }
00078 else
00079 {
00080 ACE_MT (result = this->token_.acquire ());
00081 }
00082
00083 // Now that this thread owns the token let us make
00084 // Check for timeouts and errors.
00085 if (result == -1)
00086 {
00087 if (errno == ETIME)
00088 return 0;
00089 else
00090 return -1;
00091 }
00092
00093 // We got the token and so let us mark ourseleves as owner
00094 this->owner_ = 1;
00095
00096 return result;
00097 }
|
|
|
A helper method that grabs the token for us, after which the thread that owns that can do some actual work.
Definition at line 19 of file TP_Reactor.cpp. References ACE_MT, ACE_TRACE, ETIME, ACE_OS::gettimeofday, ACE_TP_Reactor::no_op_sleep_hook, and owner_. Referenced by ACE_TP_Reactor::handle_events.
00020 {
00021 ACE_TRACE ("ACE_TP_Token_Guard::grab_token");
00022
00023 // The order of these events is very subtle, modify with care.
00024
00025 // Try to grab the lock. If someone if already there, don't wake
00026 // them up, just queue up in the thread pool.
00027 int result = 0;
00028
00029 if (max_wait_time)
00030 {
00031 ACE_Time_Value tv = ACE_OS::gettimeofday ();
00032 tv += *max_wait_time;
00033
00034 ACE_MT (result = this->token_.acquire_read (&ACE_TP_Reactor::no_op_sleep_hook,
00035 0,
00036 &tv));
00037 }
00038 else
00039 {
00040 ACE_MT (result = this->token_.acquire_read (&ACE_TP_Reactor::no_op_sleep_hook));
00041 }
00042
00043 // Now that this thread owns the token let us make
00044 // Check for timeouts and errors.
00045 if (result == -1)
00046 {
00047 if (errno == ETIME)
00048 return 0;
00049 else
00050 return -1;
00051 }
00052
00053 // We got the token and so let us mark ourselves as owner
00054 this->owner_ = 1;
00055
00056 return result;
00057 }
|
|
|
Returns whether the thread that created this object ownes the token or not.
Definition at line 81 of file TP_Reactor.i. References owner_. Referenced by ACE_TP_Reactor::handle_events, and ACE_TP_Reactor::remove_handler.
00082 {
00083 return this->owner_;
00084 }
|
|
|
Release the token ..
Definition at line 69 of file TP_Reactor.i. References ACE_MT, and owner_. Referenced by ACE_TP_Reactor::handle_notify_events, ACE_TP_Reactor::handle_socket_events, and ACE_TP_Reactor::handle_timer_events.
|
|
|
Flag that indicate whether the thread that created this object owns the token or not. A value of 0 indicates that this class hasnt got the token (and hence the thread) and a value of 1 vice-versa.
Definition at line 126 of file TP_Reactor.h. Referenced by acquire_token, grab_token, is_owner, release_token, and ~ACE_TP_Token_Guard. |
|
|
The Select Reactor token.
Definition at line 120 of file TP_Reactor.h. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002