#include <POSIX_CB_Proactor.h>
Inheritance diagram for ACE_POSIX_CB_Proactor:
Public Member Functions | |
virtual Proactor_Type | get_impl_type (void) |
virtual | ~ACE_POSIX_CB_Proactor (void) |
Destructor. | |
ACE_POSIX_CB_Proactor (size_t max_aio_operations=ACE_AIO_DEFAULT_SIZE) | |
Static Public Member Functions | |
void | aio_completion_func (sigval_t cb_data) |
Protected Member Functions | |
virtual int | handle_events (ACE_Time_Value &wait_time) |
virtual int | handle_events (void) |
virtual ssize_t | allocate_aio_slot (ACE_POSIX_Asynch_Result *result) |
Find free slot to store result and aiocb pointer. | |
virtual int | notify_completion (int sig_num) |
int | handle_events_i (u_long milli_seconds) |
Protected Attributes | |
ACE_SYNCH_SEMAPHORE | sema_ |
Definition at line 42 of file POSIX_CB_Proactor.h.
|
Destructor.
Definition at line 30 of file POSIX_CB_Proactor.cpp. References ACE_POSIX_AIOCB_Proactor::close().
00031 { 00032 this->close (); 00033 } |
|
Constructor defines max number asynchronous operations that can be started at the same time. Definition at line 18 of file POSIX_CB_Proactor.cpp. References ACE_POSIX_Proactor::get_asynch_pseudo_task(), and ACE_Asynch_Pseudo_Task::start().
00019 : ACE_POSIX_AIOCB_Proactor (max_aio_operations, 00020 ACE_POSIX_Proactor::PROACTOR_CB), 00021 sema_ ((unsigned int) 0) 00022 { 00023 // we should start pseudo-asynchronous accept task 00024 // one per all future acceptors 00025 00026 this->get_asynch_pseudo_task ().start (); 00027 } |
|
Definition at line 41 of file POSIX_CB_Proactor.cpp. References notify_completion(). Referenced by allocate_aio_slot().
00042 { 00043 ACE_POSIX_CB_Proactor * impl = static_cast<ACE_POSIX_CB_Proactor *> (cb_data.sival_ptr); 00044 if ( impl != 0 ) 00045 impl->notify_completion (0); 00046 } |
|
Find free slot to store result and aiocb pointer.
Reimplemented from ACE_POSIX_AIOCB_Proactor. Definition at line 80 of file POSIX_CB_Proactor.cpp. References aio_completion_func(), ACE_POSIX_AIOCB_Proactor::allocate_aio_slot(), and ssize_t.
00081 { 00082 ssize_t slot = ACE_POSIX_AIOCB_Proactor::allocate_aio_slot (result); 00083 if (slot == -1) 00084 return -1; 00085 00086 // setup OS notification methods for this aio 00087 // @@ TODO: This gets the completion method back to this proactor to 00088 // find the completed aiocb. It would be so much better to not only get 00089 // the proactor, but the aiocb as well. 00090 #if defined(__sgi) 00091 result->aio_sigevent.sigev_notify = SIGEV_CALLBACK; 00092 result->aio_sigevent.sigev_func = aio_completion_func ; 00093 #else 00094 result->aio_sigevent.sigev_notify = SIGEV_THREAD; 00095 # if defined (ACE_HAS_SIG_C_FUNC) 00096 result->aio_sigevent.sigev_notify_function = 00097 ACE_POSIX_CB_Proactor_aio_completion; 00098 # else 00099 result->aio_sigevent.sigev_notify_function = aio_completion_func; 00100 # endif /* ACE_HAS_SIG_C_FUNC */ 00101 result->aio_sigevent.sigev_notify_attributes = 0; 00102 #endif /* __sgi */ 00103 00104 result->aio_sigevent.sigev_value.sival_ptr = this ; 00105 00106 return slot; 00107 } |
|
Reimplemented from ACE_POSIX_AIOCB_Proactor. Definition at line 36 of file POSIX_CB_Proactor.cpp.
00037 { 00038 return PROACTOR_CB; 00039 } |
|
Block indefinitely until at least one event is dispatched. Dispatch a single set of events. If elapses before any events occur, return 0. Return 1 on success i.e., when a completion is dispatched, non-zero (-1) on errors and errno is set accordingly. Reimplemented from ACE_POSIX_AIOCB_Proactor. Definition at line 65 of file POSIX_CB_Proactor.cpp. References ACE_INFINITE, and handle_events_i().
00066 { 00067 return this->handle_events_i (ACE_INFINITE); 00068 } |
|
Dispatch a single set of events. If elapses before any events occur, return 0. Return 1 on success i.e., when a completion is dispatched, non-zero (-1) on errors and errno is set accordingly. Reimplemented from ACE_POSIX_AIOCB_Proactor. Definition at line 57 of file POSIX_CB_Proactor.cpp. References handle_events_i(), and ACE_Time_Value::msec().
00058 { 00059 // Decrement <wait_time> with the amount of time spent in the method 00060 ACE_Countdown_Time countdown (&wait_time); 00061 return this->handle_events_i (wait_time.msec ()); 00062 } |
|
Dispatch a single set of events. If elapses before any events occur, return 0. Return 1 if a completion is dispatched. Return -1 on errors. Reimplemented from ACE_POSIX_AIOCB_Proactor. Definition at line 110 of file POSIX_CB_Proactor.cpp. References ACE_ERROR, ACE_INFINITE, ACE_Time_Value, ACE_POSIX_Proactor::application_specific_code(), ETIME, ACE_POSIX_AIOCB_Proactor::find_completed_aio(), ACE_OS::gettimeofday(), LM_ERROR, and ACE_POSIX_AIOCB_Proactor::process_result_queue(). Referenced by handle_events().
00111 { 00112 00113 int result_wait=0; 00114 00115 // Wait for the signals. 00116 if (milli_seconds == ACE_INFINITE) 00117 { 00118 result_wait = this->sema_.acquire(); 00119 } 00120 else 00121 { 00122 // Wait for <milli_seconds> amount of time. 00123 ACE_Time_Value abs_time = ACE_OS::gettimeofday () 00124 + ACE_Time_Value (0, milli_seconds * 1000); 00125 00126 result_wait = this->sema_.acquire(abs_time); 00127 } 00128 00129 // Check for errors 00130 // but let continue work in case of errors 00131 // we should check "post_completed" queue 00132 if (result_wait == -1) 00133 { 00134 if (errno != ETIME && // timeout 00135 errno != EINTR ) // interrupted system call 00136 ACE_ERROR ((LM_ERROR, 00137 "%N:%l:(%P | %t)::%p\n", 00138 "ACE_POSIX_CB_Proactor::handle_events:" 00139 "semaphore acquire failed" 00140 )); 00141 } 00142 00143 size_t index = 0; // start index to scan aiocb list 00144 size_t count = this->aiocb_list_max_size_; // max number to iterate 00145 00146 int error_status = 0; 00147 size_t return_status = 0; 00148 00149 int ret_aio = 0; 00150 int ret_que = 0; 00151 00152 for (;; ret_aio++) 00153 { 00154 ACE_POSIX_Asynch_Result * asynch_result = 00155 this->find_completed_aio (error_status, 00156 return_status, 00157 index, 00158 count); 00159 00160 if (asynch_result == 0) 00161 break; 00162 00163 // Call the application code. 00164 this->application_specific_code (asynch_result, 00165 return_status, // Bytes transferred. 00166 0, // No completion key. 00167 error_status); // Error 00168 } 00169 00170 // process post_completed results 00171 ret_que = this->process_result_queue (); 00172 00173 // Uncomment this if you want to test 00174 // and research the behavior of you system 00175 // ACE_DEBUG ((LM_DEBUG, 00176 // "(%t) NumAIO=%d NumQueue=%d\n", 00177 // ret_aio, ret_que)); 00178 00179 return ret_aio + ret_que > 0 ? 1 : 0; 00180 } |
|
Notify queue of "post_completed" ACE_POSIX_Asynch_Results called from post_completion method Reimplemented from ACE_POSIX_AIOCB_Proactor. Definition at line 71 of file POSIX_CB_Proactor.cpp. Referenced by aio_completion_func().
00072 { 00073 ACE_UNUSED_ARG (sig_num); 00074 00075 return this->sema_.release(); 00076 } |
|
semaphore variable to notify used to wait the first AIO start Definition at line 94 of file POSIX_CB_Proactor.h. |