#include <TP_Reactor.h>
Public Member Functions | |
ACE_TP_Token_Guard (ACE_Select_Reactor_Token &token) | |
Constructor that will grab the token for us. | |
~ACE_TP_Token_Guard (void) | |
void | release_token (void) |
Release the token .. | |
int | is_owner (void) |
int | acquire_read_token (ACE_Time_Value *max_wait_time=0) |
int | acquire_token (ACE_Time_Value *max_wait_time=0) |
Private Member Functions | |
ACE_TP_Token_Guard (void) | |
ACE_TP_Token_Guard (const ACE_TP_Token_Guard &) | |
ACE_TP_Token_Guard & | operator= (const ACE_TP_Token_Guard &) |
Private Attributes | |
ACE_Select_Reactor_Token & | token_ |
The Select Reactor token. | |
int | owner_ |
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 88 of file TP_Reactor.h.
|
Constructor that will grab the token for us.
Definition at line 52 of file TP_Reactor.inl.
|
|
Destructor. This will release the token if it hasnt been released till this point Definition at line 60 of file TP_Reactor.inl.
|
|
|
|
|
|
A helper method that grabs the token for us, after which the thread that owns that can do some actual work. Definition at line 23 of file TP_Reactor.cpp. References ACE_TRACE, ETIME, and ACE_OS::gettimeofday(). Referenced by ACE_TP_Reactor::handle_events().
00024 { 00025 ACE_TRACE ("ACE_TP_Token_Guard::acquire_read_token"); 00026 00027 // The order of these events is very subtle, modify with care. 00028 00029 // Try to grab the lock. If someone if already there, don't wake 00030 // them up, just queue up in the thread pool. 00031 int result = 0; 00032 00033 if (max_wait_time) 00034 { 00035 ACE_Time_Value tv = ACE_OS::gettimeofday (); 00036 tv += *max_wait_time; 00037 00038 ACE_MT (result = this->token_.acquire_read (&ACE_TP_Reactor::no_op_sleep_hook, 00039 0, 00040 &tv)); 00041 } 00042 else 00043 { 00044 ACE_MT (result = this->token_.acquire_read (&ACE_TP_Reactor::no_op_sleep_hook)); 00045 } 00046 00047 // Check for timeouts and errors. 00048 if (result == -1) 00049 { 00050 if (errno == ETIME) 00051 return 0; 00052 else 00053 return -1; 00054 } 00055 00056 // We got the token and so let us mark ourselves as owner 00057 this->owner_ = 1; 00058 00059 return result; 00060 } |
|
A helper method that grabs the token for us, after which the thread that owns that can do some actual work. This differs from acquire_read_token() as it uses acquire () to get the token instead of acquire_read () Definition at line 63 of file TP_Reactor.cpp. References ACE_TRACE, ETIME, and ACE_OS::gettimeofday(). Referenced by ACE_TP_Reactor::post_process_socket_event().
00064 { 00065 ACE_TRACE ("ACE_TP_Token_Guard::acquire_token"); 00066 00067 // Try to grab the lock. If someone if already there, don't wake 00068 // them up, just queue up in the thread pool. 00069 int result = 0; 00070 00071 if (max_wait_time) 00072 { 00073 ACE_Time_Value tv = ACE_OS::gettimeofday (); 00074 tv += *max_wait_time; 00075 00076 ACE_MT (result = this->token_.acquire (0, 00077 0, 00078 &tv)); 00079 } 00080 else 00081 { 00082 ACE_MT (result = this->token_.acquire ()); 00083 } 00084 00085 // Check for timeouts and errors. 00086 if (result == -1) 00087 { 00088 if (errno == ETIME) 00089 return 0; 00090 else 00091 return -1; 00092 } 00093 00094 // We got the token and so let us mark ourselves as owner 00095 this->owner_ = 1; 00096 00097 return result; 00098 } |
|
Returns whether the thread that created this object ownes the token or not. Definition at line 82 of file TP_Reactor.inl. Referenced by ACE_TP_Reactor::handle_events(), and ACE_TP_Reactor::post_process_socket_event().
00083 { 00084 return this->owner_; 00085 } |
|
|
|
Release the token ..
Definition at line 70 of file TP_Reactor.inl. 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 136 of file TP_Reactor.h. |
|
The Select Reactor token.
Definition at line 130 of file TP_Reactor.h. |