#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 261 of file Svc_Handler.h.
|
||||||||||||||||||||||||||||
|
Constructor initializes the and by passing them down to the 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 415 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_.
00420 : ACE_Svc_Handler<PR_ST_2, ACE_SYNCH_USE> (tm, mq, reactor), 00421 maximum_buffer_size_ (maximum_buffer_size), 00422 current_buffer_size_ (0), 00423 timeoutp_ (timeout) 00424 { 00425 ACE_TRACE ("ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::ACE_Buffered_Svc_Handler"); 00426 00427 if (this->timeoutp_ != 0) 00428 { 00429 this->interval_ = *timeout; 00430 this->next_timeout_ = ACE_OS::gettimeofday () + this->interval_; 00431 } 00432 } |
|
||||||||||
|
Destructor, which calls .
Definition at line 409 of file Svc_Handler.cpp. References ACE_Buffered_Svc_Handler<, >::flush().
00410 {
00411 this->flush ();
00412 }
|
|
||||||||||
|
Dump the state of an object.
Reimplemented from ACE_Svc_Handler< ACE_PEER_STREAM_2, ACE_SYNCH_USE >. Definition at line 495 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().
00496 {
00497 #if defined (ACE_HAS_DUMP)
00498 ACE_TRACE ("ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::dump");
00499
00500 ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::dump ();
00501 ACE_DEBUG ((LM_DEBUG,
00502 "maximum_buffer_size_ = %d\n",
00503 this->maximum_buffer_size_));
00504 ACE_DEBUG ((LM_DEBUG,
00505 "current_buffer_size_ = %d\n",
00506 this->current_buffer_size_));
00507 if (this->timeoutp_ != 0)
00508 ACE_DEBUG ((LM_DEBUG,
00509 "next_timeout_.sec = %d, next_timeout_.usec = %d\n",
00510 this->next_timeout_.sec (),
00511 this->next_timeout_.usec ()));
00512 #endif /* ACE_HAS_DUMP */
00513 }
|
|
||||||||||
|
Flush the ACE_Message_Queue, which writes all the queued ACE_Message_Blocks to the . Definition at line 462 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().
00463 {
00464 ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, m, this->msg_queue ()->lock (), -1);
00465
00466 return this->flush_i ();
00467 }
|
|
||||||||||
|
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 470 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().
00471 {
00472 ACE_Message_Queue_Iterator<ACE_SYNCH_USE> iterator (*this->msg_queue ());
00473 ACE_Message_Block *mblk = 0;
00474 ssize_t result = 0;
00475
00476 // Get the first <ACE_Message_Block> so that we can write everything
00477 // out via the <send_n>.
00478 if (iterator.next (mblk) != 0)
00479 result = this->peer ().send_n (mblk);
00480
00481 // This method assumes the caller holds the queue's lock!
00482 if (result != -1)
00483 this->msg_queue ()->flush_i ();
00484
00485 if (this->timeoutp_ != 0)
00486 // Update the next timeout period by adding the interval.
00487 this->next_timeout_ += this->interval_;
00488
00489 this->current_buffer_size_ = 0;
00490
00491 return result;
00492 }
|
|
||||||||||||||||
|
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 516 of file Svc_Handler.cpp. References ACE_TRACE.
00518 {
00519 ACE_TRACE ("ACE_Buffered_Svc_Handler<PR_ST_2, ACE_SYNCH_USE>::handle_timeout");
00520 return 0;
00521 }
|
|
||||||||||||||||
|
Insert the ACE_Message_Block chain rooted at into the ACE_Message_Queue with the designated . 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 435 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().
00437 {
00438 ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, m, this->msg_queue ()->lock (), -1);
00439
00440 // Enqueue <mb> onto the message queue.
00441 if (this->putq (mb, tv) == -1)
00442 return -1;
00443 else
00444 {
00445 // Update the current number of bytes on the queue.
00446 this->current_buffer_size_ += mb->total_size ();
00447
00448 // Flush the buffer when the number of bytes exceeds the maximum
00449 // buffer size or when the timeout period has elapsed.
00450 if (this->current_buffer_size_ >= this->maximum_buffer_size_
00451 || (this->timeoutp_ != 0
00452 && this->next_timeout_ <= ACE_OS::gettimeofday ()))
00453 return this->flush_i ();
00454 else
00455 return 0;
00456 }
00457 }
|
|
|||||
|
Current size in bytes of the contents.
Definition at line 316 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 322 of file Svc_Handler.h. |
|
|||||
|
Maximum size the can be before we have to flush the buffer. Definition at line 313 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 319 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 325 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(). |
1.3.6