Public Member Functions | Static Public Member Functions | Data Fields

OneWayMultiTunnel Struct Reference

A generic state machine that connects a source virtual conection to multiple target virtual connections. More...

#include <I_OneWayMultiTunnel.h>

Inherits OneWayTunnel.

Collaboration diagram for OneWayMultiTunnel:
Collaboration graph
[legend]

Public Member Functions

 OneWayMultiTunnel ()
void init (VConnection *vcSource, VConnection **vcTargets, int n_vcTargets, Continuation *aCont=NULL, int size_estimate=0, int64_t nbytes=TUNNEL_TILL_DONE, bool asingle_buffer=true, bool aclose_source=true, bool aclose_target=true, Transform_fn manipulate_fn=NULL, int water_mark=0)
 This init function sets up the read (calls do_io_read) and the write (calls do_io_write).
void init (Continuation *aCont, VIO *SourceVio, VIO **TargetVios, int n_vioTargets, bool aclose_source=true, bool aclose_target=true)
 Use this init function if both the read and the write sides have already been setup.
int startEvent (int event, void *data)
virtual void reenable_all ()
virtual void close_target_vio (int result, VIO *vio=NULL)

Static Public Member Functions

static OneWayMultiTunnelOneWayMultiTunnel_alloc ()
 Allocates a OneWayMultiTunnel object.
static void OneWayMultiTunnel_free (OneWayMultiTunnel *)
 Deallocates a OneWayTunnel object.

Data Fields

int n_vioTargets
VIOvioTargets [ONE_WAY_MULTI_TUNNEL_LIMIT]
MIOBufferAccessor topOutBuffer
bool source_read_previously_completed

Detailed Description

A generic state machine that connects a source virtual conection to multiple target virtual connections.

A OneWayMultiTunnel is similar to the OneWayTunnel module. However, instead of connection one source to one target, it connects multiple virtual connections - a source vc and multiple target vcs, and copies the data from the source to the target vcs. The maximum number of Target VCs is limited by ONE_WAY_MULTI_TUNNEL_LIMIT.

If manipulate_fn is not NULL, then the tunnel acts as a filter, processing all data arriving from the source vc by the manipulate_fn function, before sending to the target vcs. By default, the manipulate_fn is set to NULL, yielding the identity function.

See also:
OneWayTunnel

Definition at line 56 of file I_OneWayMultiTunnel.h.


Constructor & Destructor Documentation

OneWayMultiTunnel::OneWayMultiTunnel (  ) 

Definition at line 42 of file OneWayMultiTunnel.cc.


Member Function Documentation

void OneWayMultiTunnel::close_target_vio ( int  result,
VIO vio = NULL 
) [virtual]
void OneWayMultiTunnel::init ( Continuation aCont,
VIO SourceVio,
VIO **  TargetVios,
int  n_vioTargets,
bool  aclose_source = true,
bool  aclose_target = true 
)

Use this init function if both the read and the write sides have already been setup.

The tunnel assumes that the read VC and the write VCs are using the same buffer and frees that buffer when the transfer is done (either successful or unsuccessful).

Parameters:
aCont continuation to call back when the tunnel finishes. If not specified, the tunnel deallocates itself without calling back anybody.
SourceVio read VIO of the Source VC.
TargetVios array of write VIOs of the Target VCs.
n_vioTargets size of TargetVios array.
aclose_source if true, the tunnel closes vcSource at the end. If aCont is not specified, this should be set to true.
aclose_target ff true, the tunnel closes vcTarget at the end. If aCont is not specified, this should be set to true.

Definition at line 109 of file OneWayMultiTunnel.cc.

References VIO::buffer, OneWayTunnel::close_source, OneWayTunnel::close_target, OneWayTunnel::cont, OneWayTunnel::manipulate_fn, Continuation::mutex, OneWayTunnel::n_connections, n_vioTargets, new_ProxyMutex(), VIO::ntodo(), VIO::set_continuation(), SET_HANDLER, OneWayTunnel::single_buffer, source_read_previously_completed, startEvent(), topOutBuffer, OneWayTunnel::tunnel_till_done, OneWayTunnel::vioSource, vioTargets, MIOBufferAccessor::writer(), and MIOBufferAccessor::writer_for().

void OneWayMultiTunnel::init ( VConnection vcSource,
VConnection **  vcTargets,
int  n_vcTargets,
Continuation aCont = NULL,
int  size_estimate = 0,
int64_t  nbytes = TUNNEL_TILL_DONE,
bool  asingle_buffer = true,
bool  aclose_source = true,
bool  aclose_target = true,
Transform_fn  manipulate_fn = NULL,
int  water_mark = 0 
)

This init function sets up the read (calls do_io_read) and the write (calls do_io_write).

Parameters:
vcSource source VConnection. A do_io_read should not have been called on the vcSource. The tunnel calls do_io_read on this VC.
vcTargets array of Target VConnections. A do_io_write should not have been called on any of the vcTargets. The tunnel calls do_io_write on these VCs.
n_vcTargets size of vcTargets.
aCont continuation to call back when the tunnel finishes. If not specified, the tunnel deallocates itself without calling back anybody.
size_estimate size of the MIOBuffer to create for reading/ writing to/from the VC's.
nbytes number of bytes to transfer.
asingle_buffer whether the same buffer should be used to read from vcSource and write to vcTarget. This should be set to true in most cases, unless the data needs be transformed.
aclose_source if true, the tunnel closes vcSource at the end. If aCont is not specified, this should be set to true.
aclose_target if true, the tunnel closes vcTarget at the end. If aCont is not specified, this should be set to true.
manipulate_fn if specified, the tunnel calls this function with the input and the output buffer, whenever it gets new data in the input buffer. This function can transform the data in the input buffer.
water_mark for the MIOBuffer used for reading.

Definition at line 62 of file OneWayMultiTunnel.cc.

References buffer_size_to_index(), OneWayTunnel::close_source, OneWayTunnel::close_target, OneWayTunnel::cont, default_large_iobuffer_size, VConnection::do_io(), ink_assert, INT64_MAX, OneWayTunnel::manipulate_fn, Continuation::mutex, OneWayTunnel::n_connections, n_vioTargets, new_MIOBuffer, new_ProxyMutex(), ONE_WAY_MULTI_TUNNEL_LIMIT, VIO::READ, SET_HANDLER, OneWayTunnel::single_buffer, source_read_previously_completed, startEvent(), topOutBuffer, OneWayTunnel::tunnel_till_done, OneWayTunnel::vioSource, vioTargets, MIOBuffer::water_mark, VIO::WRITE, and MIOBufferAccessor::writer_for().

OneWayMultiTunnel * OneWayMultiTunnel::OneWayMultiTunnel_alloc (  )  [static]

Allocates a OneWayMultiTunnel object.

Returns:
new OneWayTunnel object.

Definition at line 48 of file OneWayMultiTunnel.cc.

References OneWayMultiTunnelAllocator.

void OneWayMultiTunnel::OneWayMultiTunnel_free ( OneWayMultiTunnel pOWT  )  [static]

Deallocates a OneWayTunnel object.

Definition at line 54 of file OneWayMultiTunnel.cc.

References Continuation::mutex, and OneWayMultiTunnelAllocator.

void OneWayMultiTunnel::reenable_all (  )  [virtual]

Reimplemented from OneWayTunnel.

Definition at line 249 of file OneWayMultiTunnel.cc.

References n_vioTargets, VIO::reenable(), OneWayTunnel::vioSource, and vioTargets.

int OneWayMultiTunnel::startEvent ( int  event,
void *  data 
)

Field Documentation

Definition at line 147 of file I_OneWayMultiTunnel.h.

Referenced by close_target_vio(), init(), reenable_all(), and startEvent().

Definition at line 150 of file I_OneWayMultiTunnel.h.

Referenced by init(), and startEvent().

Definition at line 149 of file I_OneWayMultiTunnel.h.

Referenced by init(), and startEvent().

VIO* OneWayMultiTunnel::vioTargets[ONE_WAY_MULTI_TUNNEL_LIMIT]

Definition at line 148 of file I_OneWayMultiTunnel.h.

Referenced by close_target_vio(), init(), reenable_all(), and startEvent().


The documentation for this struct was generated from the following files: