Bobox
Classes | Public Member Functions | Private Member Functions
bobox::basic_box Class Reference

The base class for most cases. More...

#include <bobox_basic_box.hpp>

Inheritance diagram for bobox::basic_box:
bobox::box bobox::dummy_box bobox::envelope_split_box bobox::group_box bobox::init_box bobox::rr_join_box bobox::parallel_dummy_box bobox::stateful_dummy_box bobox::stateless_dummy_box

List of all members.

Classes

struct  generic_model
 Generic model for basic box. Provides implementation of bobox::box_model for most situations. More...

Public Member Functions

 basic_box (const box_parameters_pack &box_params)
 Constructor.
column allocate (const type_descriptor_ptr_type &descriptor, unsigned capacity)
 Allocate one column with the given descriptor and capacity.
envelopeallocate (const envelope_descriptor_ptr_type &descriptor)
 Creates new envelope with the given descriptor. The capacity of the envelope is chosen automatically.
envelopeallocate (const envelope_descriptor_ptr_type &descriptor, unsigned capacity)
 Creates new envelope with the given descriptor and capacity.
void async ()
 Enables waiting on asynchronous condition. See listen method.
void attach ()
 This method must be called after the blocking operation finishes. See detach .
void detach ()
 This method must be called before any blocking operation, e.g. I/O operations.
const
envelope_descriptor_ptr_type
get_inarc_descriptor (inarc_index_type inarc) const
 Gets the envelope descriptor for the given input arc.
virtual size_t get_inarcs_count () const override
 Gets the number of input arcs.
unsigned get_inarcs_count (input_index_type input)
 Gets the number of arcs in the given input.
unsigned get_input_columns_count (input_index_type input)
 Gets the number of columns in the given input.
const
envelope_descriptor_ptr_type
get_input_descriptor (input_index_type input) const
 Gets the envelope descriptor for the given input.
const type_descriptors_ptr_typeget_input_descriptors (input_index_type input) const
 Gets the type descriptors of all columns for the given input.
unsigned get_inputs_count () const
 Gets the number of inputs.
unsigned get_optimal_capacity (const envelope_descriptor_ptr_type &descriptor) const
 Gets an optimal capacity of the envelope for the given descriptor.
const
envelope_descriptor_ptr_type
get_outarc_descriptor (outarc_index_type outarc) const
 Gets the envelope descriptor for the given output arc.
virtual size_t get_outarcs_count () const override
 Gets the number of output arcs.
unsigned get_outarcs_count (output_index_type output)
 Gets the number of arcs in the given output.
unsigned get_output_columns_count (output_index_type output)
 Gets the number of columns in the given output.
const
envelope_descriptor_ptr_type
get_output_descriptor (output_index_type output) const
 Gets the envelope descriptor for the given output.
const type_descriptors_ptr_typeget_output_descriptors (output_index_type output) const
 Gets the type descriptors of all columns for the given output.
unsigned get_outputs_count () const
 Gets the number of outputs.
std::tuple< input_index_type,
inarc_index_type > 
inarc_to_input (inarc_index_type inarc) const
 Converts the given input arc to input.
inarc_index_type input_to_inarc (input_index_type input) const
 Converts the given input to input arc.
inarc_index_type input_to_inarc (input_index_type input, inarc_index_type offset) const
 Converts the given input to input arc.
void listen (inarc_index_type inarc)
 Enables listening on the given input arc. This enables asynchronous processing of envelopes, however, this feature is currently under development.
std::tuple< output_index_type,
outarc_index_type > 
outarc_to_output (outarc_index_type outarc) const
 Converts the given output arc to output.
outarc_index_type output_to_outarc (output_index_type output) const
 Converts the given output to output arc.
outarc_index_type output_to_outarc (output_index_type output, outarc_index_type offset) const
 Converts the given output to output arc.
envelope_ptr_type pop_envelope (input_index_type input)
 Pops the envelope from the given input. If the input buffer is empty, the function blocks until an envelope is received.
envelope_ptr_type pop_envelope (input_index_type input, inarc_index_type offset)
 Pops the envelope from the given input. If the input buffer is empty, the function blocks until an envelope is received.
envelope_ptr_type pop_envelope (inarc_index_type inarc)
 Pops the envelope from the given input arc. If the input buffer is empty, the function blocks until an envelope is received.
bool prefetch_envelope (input_index_type input, unsigned count=1)
 Prefetches count envelopes on the given input. This means, that next call of sync_body and wait will wait until at least count envelopes is in the input buffer.
bool prefetch_envelope (input_index_type input, inarc_index_type offset, unsigned count=1)
 Prefetches count envelopes on the given input. This means, that next call of sync_body and wait will wait until at least count envelopes is in the input buffer.
bool prefetch_envelope (inarc_index_type inarc, unsigned count=1)
 Prefetches count envelopes on the given input arc. This means, that next call of sync_body and wait will wait until at least count envelopes is in the input buffer.
void send_envelope (output_index_type output, const envelope_ptr_type &env)
 Sends the envelope to the given output.
void send_envelope (output_index_type output, outarc_index_type offset, const envelope_ptr_type &env)
 Sends the envelope to the given output.
void send_envelope (outarc_index_type outarc, const envelope_ptr_type &env)
 Sends the envelope to the given output arc.
void send_poisoned (output_index_type output)
 Sends the poisoned envelope to the given output.
void send_poisoned (output_index_type output, outarc_index_type offset)
 Sends the poisoned envelope to the given output.
void send_poisoned (outarc_index_type outarc)
 Sends the poisoned envelope to the given output arc.
envelope_ptr_type try_pop_envelope (input_index_type input)
 Tries to receive an envelope from the given input. If there is an envelope in the input buffer, it is poped from the buffer and returned, otherwise null is returned.
envelope_ptr_type try_pop_envelope (input_index_type input, inarc_index_type offset)
 Tries to receive an envelope from the given input. If there is an envelope in the input buffer, it is poped from the buffer and returned, otherwise null is returned.
envelope_ptr_type try_pop_envelope (inarc_index_type inarc)
 Tries to receive an envelope from the given input arc. If there is an envelope in the input buffer, it is poped from the buffer and returned, otherwise null is returned.
void unlisten (inarc_index_type input)
 Disables listening on the given input arc. See listen method.
void wait ()
 Waits until all prefetched envelopes are received and asynchronous condition is met. See prefetch_envelope and listen .
void yield ()
 Gives up the CPU for a while.

Private Member Functions

virtual bool async_body (inarc_index_type inarc)
 This method is called automatically when an envelope is received on the input which is being listened.
virtual void sync_body ()
 This method is called automatically when all prefetched envelopes are received and asynchronous condition is met.

Detailed Description

The base class for most cases.

All you have to do is to override methods init_impl and sync_body. In the method init_impl only const methods and allocate and prefetch_envelope are allowed to be called.


Member Function Documentation

virtual bool bobox::basic_box::async_body ( inarc_index_type  inarc) [private, virtual]

This method is called automatically when an envelope is received on the input which is being listened.

Returns:
true if the asynchronous condition is met, false otherwise
Remarks:
This method is expected to be overrided.
virtual void bobox::basic_box::sync_body ( ) [private, virtual]

This method is called automatically when all prefetched envelopes are received and asynchronous condition is met.

Remarks:
This method is expected to be overrided.

The documentation for this class was generated from the following file: