#include <Dev_Poll_Reactor.h>
Collaboration diagram for ACE_Dev_Poll_Reactor::Token_Guard:
Public Member Functions | |
Token_Guard (ACE_Dev_Poll_Reactor_Token &token) | |
Constructor that will grab the token for us. | |
~Token_Guard (void) | |
void | release_token (void) |
Release the token .. | |
int | is_owner (void) |
int | acquire_quietly (ACE_Time_Value *max_wait=0) |
int | acquire (ACE_Time_Value *max_wait=0) |
Private Member Functions | |
Token_Guard (void) | |
Private Attributes | |
ACE_Dev_Poll_Reactor_Token & | token_ |
The Reactor token. | |
int | owner_ |
Definition at line 1174 of file Dev_Poll_Reactor.h.
|
Constructor that will grab the token for us.
Definition at line 193 of file Dev_Poll_Reactor.inl. References ACE_Dev_Poll_Reactor_Token.
|
|
Destructor. This will release the token if it hasn't been released till this point Definition at line 201 of file Dev_Poll_Reactor.inl. References owner_.
|
|
|
|
A helper method that acquires the token at a high priority, and does wake the current token holder. Definition at line 2613 of file Dev_Poll_Reactor.cpp. References ACE_TRACE, ETIME, ACE_OS::gettimeofday(), and owner_.
02614 { 02615 ACE_TRACE ("ACE_Dev_Poll_Reactor::Token_Guard::acquire"); 02616 02617 // Try to grab the token. If someone if already there, don't wake 02618 // them up, just queue up in the thread pool. 02619 int result = 0; 02620 if (max_wait) 02621 { 02622 ACE_Time_Value tv = ACE_OS::gettimeofday (); 02623 tv += *max_wait; 02624 02625 ACE_MT (result = this->token_.acquire (0, 0, &tv)); 02626 } 02627 else 02628 { 02629 ACE_MT (result = this->token_.acquire ()); 02630 } 02631 02632 // Check for timeouts and errors. 02633 if (result == -1) 02634 { 02635 if (errno == ETIME) 02636 return 0; 02637 else 02638 return -1; 02639 } 02640 02641 // We got the token and so let us mark ourseleves as owner 02642 this->owner_ = 1; 02643 02644 return result; 02645 } |
|
A helper method that acquires the token 1) at a low priority, and 2) wait quietly for the token, not waking another thread. This is appropriate for cases where a thread wants to wait for and dispatch an event, not causing an existing waiter to relinquish the token, and also queueing up behind other threads waiting to modify event records. Definition at line 2574 of file Dev_Poll_Reactor.cpp. References ACE_ERROR, ACE_TRACE, ETIME, ACE_OS::gettimeofday(), LM_ERROR, owner_, and polite_sleep_hook(). Referenced by ACE_Dev_Poll_Reactor::handle_events(), and ACE_Dev_Poll_Reactor::work_pending().
02575 { 02576 ACE_TRACE ("ACE_Dev_Poll_Reactor::Token_Guard::acquire_quietly"); 02577 02578 // Acquire the token but don't ping any waiters; just queue up politely. 02579 int result = 0; 02580 if (max_wait) 02581 { 02582 ACE_Time_Value tv = ACE_OS::gettimeofday (); 02583 tv += *max_wait; 02584 02585 ACE_MT (result = this->token_.acquire_read (&polite_sleep_hook, 02586 0, 02587 &tv)); 02588 } 02589 else 02590 { 02591 ACE_MT (result = this->token_.acquire_read (&polite_sleep_hook)); 02592 } 02593 02594 // Check for timeouts and errors. 02595 if (result == -1) 02596 { 02597 if (errno == ETIME) 02598 return 0; 02599 else 02600 { 02601 ACE_ERROR ((LM_ERROR, "%t: %p\n", "token acquire_read")); 02602 return -1; 02603 } 02604 } 02605 02606 // We got the token and so let us mark ourselves as owner 02607 this->owner_ = 1; 02608 02609 return result; 02610 } |
|
Returns whether the thread that created this object owns the token or not. Definition at line 223 of file Dev_Poll_Reactor.inl. References owner_. Referenced by ACE_Dev_Poll_Reactor::handle_events(), and ACE_Dev_Poll_Reactor::work_pending().
00224 { 00225 return this->owner_; 00226 } |
|
Release the token ..
Definition at line 211 of file Dev_Poll_Reactor.inl. References owner_. Referenced by ACE_Dev_Poll_Reactor::dispatch_io_event(), and ACE_Dev_Poll_Reactor::dispatch_timer_handler().
|
|
Flag that indicate whether the thread that created this object owns the token or not. A value of 0 indicates that this class hasn't got the token (and hence the thread) and a value of 1 vice-versa. Definition at line 1217 of file Dev_Poll_Reactor.h. Referenced by acquire(), acquire_quietly(), is_owner(), release_token(), and ~Token_Guard(). |
|
The Reactor token.
Definition at line 1211 of file Dev_Poll_Reactor.h. |