#include <Svc_Handler.h>
Inheritance diagram for ACE_Buffered_Svc_Handler<, >:
Public Member Functions | |
ACE_Buffered_Svc_Handler (ACE_Thread_Manager *thr_mgr=0, ACE_Message_Queue< ACE_SYNCH_USE > *mq=0, ACE_Reactor *reactor=ACE_Reactor::instance(), size_t max_buffer_size=0, ACE_Time_Value *relative_timeout=0) | |
virtual | ~ACE_Buffered_Svc_Handler (void) |
Destructor, which calls . | |
virtual int | put (ACE_Message_Block *message_block, ACE_Time_Value *timeout=0) |
virtual int | flush (void) |
virtual int | handle_timeout (const ACE_Time_Value &time, const void *) |
void | dump (void) const |
Dump the state of an object. | |
Protected Member Functions | |
virtual int | flush_i (void) |
Protected Attributes | |
size_t | maximum_buffer_size_ |
size_t | current_buffer_size_ |
Current size in bytes of the contents. | |
ACE_Time_Value | next_timeout_ |
Timeout value used to control when the buffer is flushed. | |
ACE_Time_Value | interval_ |
Interval of the timeout. | |
ACE_Time_Value * | timeoutp_ |
Timeout pointer. |
The buffering feature makes it possible to queue up in an ACE_Message_Queue until (1) the queue is "full" or (2) a period of time elapses, at which point the queue is "flushed" via to the peer.
Definition at line 260 of file Svc_Handler.h.
|
Constructor initializes the and by passing them down to the ACE_Task base class. The is passed to the ACE_Event_Handler. The and are used to determine at what point to flush the . By default, there's no buffering at all. The value is interpreted to be in a unit that's relative to the current time returned by <ACE_OS::gettimeofday>. Definition at line 413 of file Svc_Handler.cpp. References ACE_SYNCH_USE, ACE_TRACE, ACE_OS::gettimeofday(), ACE_Buffered_Svc_Handler<, >::next_timeout_, PR_ST_2, and ACE_Buffered_Svc_Handler<, >::timeoutp_.
00418 : ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE> (tm, mq, reactor), 00419 maximum_buffer_size_ (maximum_buffer_size), 00420 current_buffer_size_ (0), 00421 timeoutp_ (timeout) 00422 { 00423 ACE_TRACE ("ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::ACE_Buffered_Svc_Handler"); 00424 00425 if (this->timeoutp_ != 0) 00426 { 00427 this->interval_ = *timeout; 00428 this->next_timeout_ = ACE_OS::gettimeofday () + this->interval_; 00429 } 00430 } |
|
Destructor, which calls .
Definition at line 407 of file Svc_Handler.cpp. References ACE_Buffered_Svc_Handler<, >::flush().
00408 { 00409 this->flush (); 00410 } |
|
Dump the state of an object.
Reimplemented from ACE_Svc_Handler< ACE_PEER_STREAM_2, ACE_SYNCH_USE >. Definition at line 493 of file Svc_Handler.cpp. References ACE_DEBUG, ACE_TRACE, LM_DEBUG, ACE_Buffered_Svc_Handler<, >::next_timeout_, ACE_Buffered_Svc_Handler<, >::timeoutp_, and ACE_Time_Value::usec().
00494 { 00495 #if defined (ACE_HAS_DUMP) 00496 ACE_TRACE ("ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::dump"); 00497 00498 ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::dump (); 00499 ACE_DEBUG ((LM_DEBUG, 00500 "maximum_buffer_size_ = %d\n", 00501 this->maximum_buffer_size_)); 00502 ACE_DEBUG ((LM_DEBUG, 00503 "current_buffer_size_ = %d\n", 00504 this->current_buffer_size_)); 00505 if (this->timeoutp_ != 0) 00506 ACE_DEBUG ((LM_DEBUG, 00507 "next_timeout_.sec = %d, next_timeout_.usec = %d\n", 00508 this->next_timeout_.sec (), 00509 this->next_timeout_.usec ())); 00510 #endif /* ACE_HAS_DUMP */ 00511 } |
|
Flush the ACE_Message_Queue, which writes all the queued ACE_Message_Blocks to the . Definition at line 460 of file Svc_Handler.cpp. References ACE_GUARD_RETURN, ACE_SYNCH_MUTEX_T, and ACE_Buffered_Svc_Handler<, >::flush_i(). Referenced by ACE_Buffered_Svc_Handler<, >::~ACE_Buffered_Svc_Handler().
00461 { 00462 ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, m, this->msg_queue ()->lock (), -1); 00463 00464 return this->flush_i (); 00465 } |
|
Implement the flush operation on the ACE_Message_Queue, which writes all the queued ACE_Message_Blocks to the . Assumes that the caller holds the lock. Definition at line 468 of file Svc_Handler.cpp. References ACE_Buffered_Svc_Handler<, >::current_buffer_size_, ACE_Message_Queue< ACE_SYNCH_USE >::flush_i(), ACE_Task< ACE_SYNCH_USE >::msg_queue(), ACE_Message_Queue_Iterator<>::next(), ACE_Buffered_Svc_Handler<, >::next_timeout_, ACE_Svc_Handler< ACE_PEER_STREAM_2, ACE_SYNCH_USE >::peer(), ssize_t, and ACE_Buffered_Svc_Handler<, >::timeoutp_. Referenced by ACE_Buffered_Svc_Handler<, >::flush(), and ACE_Buffered_Svc_Handler<, >::put().
00469 { 00470 ACE_Message_Queue_Iterator<ACE_SYNCH_USE> iterator (*this->msg_queue ()); 00471 ACE_Message_Block *mblk = 0; 00472 ssize_t result = 0; 00473 00474 // Get the first <ACE_Message_Block> so that we can write everything 00475 // out via the <send_n>. 00476 if (iterator.next (mblk) != 0) 00477 result = this->peer ().send_n (mblk); 00478 00479 // This method assumes the caller holds the queue's lock! 00480 if (result != -1) 00481 this->msg_queue ()->flush_i (); 00482 00483 if (this->timeoutp_ != 0) 00484 // Update the next timeout period by adding the interval. 00485 this->next_timeout_ += this->interval_; 00486 00487 this->current_buffer_size_ = 0; 00488 00489 return result; 00490 } |
|
This method is not currently implemented -- this is where the integration with the would occur. Reimplemented from ACE_Svc_Handler< ACE_PEER_STREAM_2, ACE_SYNCH_USE >. Definition at line 514 of file Svc_Handler.cpp. References ACE_TRACE.
00516 { 00517 ACE_TRACE ("ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::handle_timeout"); 00518 return 0; 00519 } |
|
Insert the ACE_Message_Block chain rooted at into the ACE_Message_Queue with the designated timeout. The method will be called if this causes the number of bytes to exceed the maximum buffer size or if the timeout period has elapsed. Reimplemented from ACE_Task_Base. Definition at line 433 of file Svc_Handler.cpp. References ACE_GUARD_RETURN, ACE_SYNCH_MUTEX_T, ACE_Buffered_Svc_Handler<, >::current_buffer_size_, ACE_Buffered_Svc_Handler<, >::flush_i(), ACE_OS::gettimeofday(), ACE_Buffered_Svc_Handler<, >::maximum_buffer_size_, ACE_Buffered_Svc_Handler<, >::next_timeout_, ACE_Task< ACE_SYNCH_USE >::putq(), ACE_Buffered_Svc_Handler<, >::timeoutp_, and ACE_Message_Block::total_size().
00435 { 00436 ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, m, this->msg_queue ()->lock (), -1); 00437 00438 // Enqueue <mb> onto the message queue. 00439 if (this->putq (mb, tv) == -1) 00440 return -1; 00441 else 00442 { 00443 // Update the current number of bytes on the queue. 00444 this->current_buffer_size_ += mb->total_size (); 00445 00446 // Flush the buffer when the number of bytes exceeds the maximum 00447 // buffer size or when the timeout period has elapsed. 00448 if (this->current_buffer_size_ >= this->maximum_buffer_size_ 00449 || (this->timeoutp_ != 0 00450 && this->next_timeout_ <= ACE_OS::gettimeofday ())) 00451 return this->flush_i (); 00452 else 00453 return 0; 00454 } 00455 } |
|
Current size in bytes of the contents.
Definition at line 315 of file Svc_Handler.h. Referenced by ACE_Buffered_Svc_Handler<, >::flush_i(), and ACE_Buffered_Svc_Handler<, >::put(). |
|
Interval of the timeout.
Definition at line 321 of file Svc_Handler.h. |
|
Maximum size the can be before we have to flush the buffer. Definition at line 312 of file Svc_Handler.h. Referenced by ACE_Buffered_Svc_Handler<, >::put(). |
|
Timeout value used to control when the buffer is flushed.
Definition at line 318 of file Svc_Handler.h. Referenced by ACE_Buffered_Svc_Handler<, >::ACE_Buffered_Svc_Handler(), ACE_Buffered_Svc_Handler<, >::dump(), ACE_Buffered_Svc_Handler<, >::flush_i(), and ACE_Buffered_Svc_Handler<, >::put(). |
|
Timeout pointer.
Definition at line 324 of file Svc_Handler.h. Referenced by ACE_Buffered_Svc_Handler<, >::ACE_Buffered_Svc_Handler(), ACE_Buffered_Svc_Handler<, >::dump(), ACE_Buffered_Svc_Handler<, >::flush_i(), and ACE_Buffered_Svc_Handler<, >::put(). |