Public Member Functions | Public Attributes | Private Attributes

ACE_RMCast::Fragment Class Reference

#include <Fragment.h>

Inheritance diagram for ACE_RMCast::Fragment:
Inheritance graph
[legend]
Collaboration diagram for ACE_RMCast::Fragment:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Fragment (Parameters const &params)
virtual void send (Message_ptr m)

Public Attributes

Parameters const & params_

Private Attributes

Mutex mutex_
u64 sn_

Detailed Description

Definition at line 15 of file Fragment.h.


Constructor & Destructor Documentation

ACE_RMCast::Fragment::Fragment ( Parameters const &  params  ) 

Definition at line 8 of file Fragment.cpp.

{


Member Function Documentation

void ACE_RMCast::Fragment::send ( Message_ptr  m  )  [virtual]

Reimplemented from ACE_RMCast::Out_Element.

Definition at line 14 of file Fragment.cpp.

{
  Fragment::
  Fragment (Parameters const& params)
      : params_ (params),
        sn_ (1)
  {
  }

  void Fragment::send (Message_ptr m)
  {
    if (Data const* data = static_cast<Data const*> (m->find (Data::id)))
    {
      size_t max_payload_size (
        params_.max_packet_size () - max_service_size);

      if (data->size () <= max_payload_size)
      {
        u64 sn;
        {
          Lock l (mutex_);
          sn = sn_++;
        }

        m->add (Profile_ptr (new SN (sn)));

        out_->send (m);
        return;
      }

      char const* p = data->buf ();
      size_t size (data->size ());

      // Need fragmentation.
      //
      u32 packets (size / max_payload_size + (size % max_payload_size ? 1 : 0));

      // cerr << "size : " << size << endl
      //      << "packs: " << packets << endl;

      for (u32 i (1); i <= packets; ++i)
      {
        Message_ptr part (new Message);

        size_t s (i == packets ? size % max_payload_size : max_payload_size);

        // cerr << "pack: " << s << endl;

        u64 sn;
        {
          Lock l (mutex_);
          sn = sn_++;
        }

        part->add (Profile_ptr (new SN (sn)));
        part->add (Profile_ptr (new Part (i, packets, size)));


Member Data Documentation

Definition at line 27 of file Fragment.h.

Definition at line 24 of file Fragment.h.

Definition at line 28 of file Fragment.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Defines