STLdoc
STLdocumentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Concurrency::multitype_join< _Type, _Jtype > Class Template Reference

A multitype_join messaging block is a multi-source, single-target messaging block that combines together messages of different types from each of its sources and offers a tuple of the combined messages to its targets. More...

#include <agents.h>

Inheritance diagram for Concurrency::multitype_join< _Type, _Jtype >:
Concurrency::ISource< _Unwrap< _Type >::type >

Public Types

typedef _Unwrap< _Type >::type _Destination_type
 
typedef _Type type
 A type alias for _Type . More...
 
- Public Types inherited from Concurrency::ISource< _Unwrap< _Type >::type >
typedef _Unwrap< _Type >::type source_type
 A type alias for _Type . More...
 

Public Member Functions

 multitype_join (_Type _Tuple)
 Constructs a multitype_join messaging block. More...
 
 multitype_join (multitype_join &&_Join)
 Constructs a multitype_join messaging block. More...
 
 ~multitype_join ()
 Destroys the multitype_join messaging block. More...
 
virtual void link_target (_Inout_ ITarget< _Destination_type > *_PTarget)
 Links a target block to this multitype_join messaging block. More...
 
virtual void unlink_target (_Inout_ ITarget< _Destination_type > *_PTarget)
 Unlinks a target block from this multitype_join messaging block. More...
 
virtual void unlink_targets ()
 Unlinks all targets from this multitype_join messaging block. More...
 
virtual message< _Destination_type > * accept (runtime_object_identity _MsgId, _Inout_ ITarget< _Destination_type > *_PTarget)
 Accepts a message that was offered by this multitype_join block, transferring ownership to the caller. More...
 
virtual bool reserve (runtime_object_identity _MsgId, _Inout_ ITarget< _Destination_type > *_PTarget)
 Reserves a message previously offered by this multitype_join messaging block. More...
 
virtual message< _Destination_type > * consume (runtime_object_identity _MsgId, _Inout_ ITarget< _Destination_type > *_PTarget)
 Consumes a message previously offered by the multitype_join messaging block and successfully reserved by the target, transferring ownership to the caller. More...
 
virtual void release (runtime_object_identity _MsgId, _Inout_ ITarget< _Destination_type > *_PTarget)
 Releases a previous successful message reservation. More...
 
virtual void acquire_ref (_Inout_ ITarget< _Destination_type > *_PTarget)
 Acquires a reference count on this multitype_join messaging block, to prevent deletion. More...
 
virtual void release_ref (_Inout_ ITarget< _Destination_type > *_PTarget)
 Releases a reference count on this multiple_join messaging block. More...
 
- Public Member Functions inherited from Concurrency::ISource< _Unwrap< _Type >::type >
virtual ~ISource ()
 Destroys the ISource object. More...
 
virtual void link_target (_Inout_ ITarget< _Unwrap< _Type >::type > *_PTarget)=0
 When overridden in a derived class, links a target block to this ISource block. More...
 
virtual void unlink_target (_Inout_ ITarget< _Unwrap< _Type >::type > *_PTarget)=0
 When overridden in a derived class, unlinks a target block from this ISource block, if found to be previously linked. More...
 
virtual message< _Unwrap< _Type >::type > * accept (runtime_object_identity _MsgId, _Inout_ ITarget< _Unwrap< _Type >::type > *_PTarget)=0
 When overridden in a derived class, accepts a message that was offered by this ISource block, transferring ownership to the caller. More...
 
virtual bool reserve (runtime_object_identity _MsgId, _Inout_ ITarget< _Unwrap< _Type >::type > *_PTarget)=0
 When overridden in a derived class, reserves a message previously offered by this ISource block. More...
 
virtual message< _Unwrap< _Type >::type > * consume (runtime_object_identity _MsgId, _Inout_ ITarget< _Unwrap< _Type >::type > *_PTarget)=0
 When overridden in a derived class, consumes a message previously offered by this ISource block and successfully reserved by the target, transferring ownership to the caller. More...
 
virtual void release (runtime_object_identity _MsgId, _Inout_ ITarget< _Unwrap< _Type >::type > *_PTarget)=0
 When overridden in a derived class, releases a previous successful message reservation. More...
 
virtual void acquire_ref (_Inout_ ITarget< _Unwrap< _Type >::type > *_PTarget)=0
 When overridden in a derived class, acquires a reference count on this ISource block, to prevent deletion. More...
 
virtual void release_ref (_Inout_ ITarget< _Unwrap< _Type >::type > *_PTarget)=0
 When overridden in a derived class, releases a reference count on this ISource block. More...
 

Private Types

template<int _Index>
using _Source_type = typename std::remove_pointer_t< std::tuple_element_t< _Index, _Type >>::source_type
 
template<int _Index>
using _Order_node_base_source_type = _Order_node_base< _Source_type< _Index >>
 

Private Member Functions

template<int _Index>
void _Initialize_joins ()
 Constructs and initializes a _Order_node for each tuple messaging block passed in. More...
 
template<>
void _Initialize_joins ()
 Provides a sentinel template specialization for _Initialize_joins recursive template expansion. More...
 
template<int _Index>
void _Delete_joins ()
 Deletes all _Order_node elements that were created in _Initialize_joins. More...
 
template<>
void _Delete_joins ()
 Provides a sentinel template specialization for _Delete_joins recursive template expansion. More...
 
multitype_join const & operator= (multitype_join const &)
 
 multitype_join (multitype_join const &)
 

Private Attributes

void_M_pSourceJoins [std::tuple_size< _Type >::value]
 
_Join_node< _Type, _Destination_type, _Jtype > * _M_pJoinNode
 
_Type _M_sourceTuple
 
Scheduler * _M_pScheduler
 
ScheduleGroup * _M_pScheduleGroup
 

Additional Inherited Members

- Protected Member Functions inherited from Concurrency::ISource< _Unwrap< _Type >::type >
void _Invoke_link_source (ITarget< _Unwrap< _Type >::type > *_PLinkFrom)
 Links this source to a target. More...
 
void _Invoke_unlink_source (ITarget< _Unwrap< _Type >::type > *_PUnlinkFrom)
 Unlinks this source from a target. More...
 

Detailed Description

template<typename _Type, join_type _Jtype = non_greedy>
class Concurrency::multitype_join< _Type, _Jtype >

A multitype_join messaging block is a multi-source, single-target messaging block that combines together messages of different types from each of its sources and offers a tuple of the combined messages to its targets.

Template Parameters
_TypeThe tuple payload type of the messages joined and propagated by the block.
_JtypeThe kind of join block this is, either greedy or non_greedy

For more information, see Asynchronous Message Blocks.

See also
choice Class, join Class, join_type Enumeration, make_join Function, make_greedy_join Function, tuple Class

Member Typedef Documentation

template<typename _Type , join_type _Jtype = non_greedy>
typedef _Unwrap<_Type>::type Concurrency::multitype_join< _Type, _Jtype >::_Destination_type
template<typename _Type , join_type _Jtype = non_greedy>
template<int _Index>
using Concurrency::multitype_join< _Type, _Jtype >::_Order_node_base_source_type = _Order_node_base<_Source_type<_Index>>
private
template<typename _Type , join_type _Jtype = non_greedy>
template<int _Index>
using Concurrency::multitype_join< _Type, _Jtype >::_Source_type = typename std::remove_pointer_t<std::tuple_element_t<_Index, _Type>>::source_type
private
template<typename _Type , join_type _Jtype = non_greedy>
typedef _Type Concurrency::multitype_join< _Type, _Jtype >::type

A type alias for _Type .

Constructor & Destructor Documentation

template<typename _Type , join_type _Jtype = non_greedy>
Concurrency::multitype_join< _Type, _Jtype >::multitype_join ( _Type  _Tuple)
inlineexplicit

Constructs a multitype_join messaging block.

Parameters
_TupleA tuple of sources for this multitype_join messaging block.

The runtime uses the default scheduler if you do not specify the _PScheduler or _PScheduleGroup parameters.

Move construction is not performed under a lock, which means that it is up to the user to make sure that there are no light-weight tasks in flight at the time of moving. Otherwise, numerous races can occur, leading to exceptions or inconsistent state.

See also
Scheduler Class, ScheduleGroup Class
12608  {
12609  _M_pJoinNode = new _Join_node<_Type, _Destination_type, _Jtype>();
12610  _Initialize_joins<0>();
12611  }
#define NULL
Definition: vcruntime.h:236
Scheduler * _M_pScheduler
Definition: agents.h:12981
_Type _M_sourceTuple
Definition: agents.h:12978
ScheduleGroup * _M_pScheduleGroup
Definition: agents.h:12984
_Join_node< _Type, _Destination_type, _Jtype > * _M_pJoinNode
Definition: agents.h:12975
template<typename _Type , join_type _Jtype = non_greedy>
Concurrency::multitype_join< _Type, _Jtype >::multitype_join ( multitype_join< _Type, _Jtype > &&  _Join)
inline

Constructs a multitype_join messaging block.

Parameters
_JoinA multitype_join messaging block to copy from. Note that the original object is orphaned, making this a move constructor.

The runtime uses the default scheduler if you do not specify the _PScheduler or _PScheduleGroup parameters.

Move construction is not performed under a lock, which means that it is up to the user to make sure that there are no light-weight tasks in flight at the time of moving. Otherwise, numerous races can occur, leading to exceptions or inconsistent state.

See also
Scheduler Class, ScheduleGroup Class
12696  {
12697  // Copy scheduler group or scheduler to the new object.
12698  _M_pScheduleGroup = _Join._M_pScheduleGroup;
12699  _M_pScheduler = _Join._M_pScheduler;
12700 
12701  // Single assignment is heap allocated, so simply copy the pointer. If it already has
12702  // a value, it will be preserved.
12703  _M_pJoinNode = _Join._M_pJoinNode;
12704  _Join._M_pJoinNode = NULL;
12705 
12706  // Invoke copy assignment for tuple to copy pointers to message blocks.
12707  _M_sourceTuple = _Join._M_sourceTuple;
12708 
12709  // Copy the pointers to order nodes to a new object and zero out in the old object.
12710  memcpy(_M_pSourceJoins, _Join._M_pSourceJoins, sizeof(_M_pSourceJoins));
12711  memset(_Join._M_pSourceJoins, 0, sizeof(_M_pSourceJoins));
12712  }
#define NULL
Definition: vcruntime.h:236
Scheduler * _M_pScheduler
Definition: agents.h:12981
_Type _M_sourceTuple
Definition: agents.h:12978
ScheduleGroup * _M_pScheduleGroup
Definition: agents.h:12984
_Join_node< _Type, _Destination_type, _Jtype > * _M_pJoinNode
Definition: agents.h:12975
void * _M_pSourceJoins[std::tuple_size< _Type >::value]
Definition: agents.h:12972
template<typename _Type , join_type _Jtype = non_greedy>
Concurrency::multitype_join< _Type, _Jtype >::~multitype_join ( )
inline

Destroys the multitype_join messaging block.

12719  {
12720  delete _M_pJoinNode;
12721  _Delete_joins<0>();
12722  }
_Join_node< _Type, _Destination_type, _Jtype > * _M_pJoinNode
Definition: agents.h:12975
template<typename _Type , join_type _Jtype = non_greedy>
Concurrency::multitype_join< _Type, _Jtype >::multitype_join ( multitype_join< _Type, _Jtype > const &  )
private

Member Function Documentation

template<typename _Type , join_type _Jtype = non_greedy>
template<int _Index>
void Concurrency::multitype_join< _Type, _Jtype >::_Delete_joins ( )
inlineprivate

Deletes all _Order_node elements that were created in _Initialize_joins.

Template Parameters
_IndexThe highest-number index of the multitype_join's sources
12956  {
12957  delete static_cast<_Order_node_base_source_type<_Index> *>(_M_pSourceJoins[_Index]);
12958  _M_pSourceJoins[_Index] = NULL;
12959  _Delete_joins<_Index + 1>();
12960  }
#define NULL
Definition: vcruntime.h:236
void * _M_pSourceJoins[std::tuple_size< _Type >::value]
Definition: agents.h:12972
template<typename _Type , join_type _Jtype = non_greedy>
template<>
void Concurrency::multitype_join< _Type, _Jtype >::_Delete_joins ( )
inlineprivate

Provides a sentinel template specialization for _Delete_joins recursive template expansion.

12968  {
12969  }
template<typename _Type , join_type _Jtype = non_greedy>
template<int _Index>
void Concurrency::multitype_join< _Type, _Jtype >::_Initialize_joins ( )
inlineprivate

Constructs and initializes a _Order_node for each tuple messaging block passed in.

Template Parameters
_IndexThe highest-number index of the multitype_join's sources
12895  {
12896  std::tuple_element_t<_Index, _Type> _Item = std::get<_Index>(_M_sourceTuple);
12897  _Order_node_base_source_type<_Index> * _Order_node_element = NULL;
12898 
12899  if (_Jtype == non_greedy)
12900  {
12901  typedef _Non_greedy_node<_Source_type<_Index>> _Non_greedy_node_source_type;
12902 
12903  if (_M_pScheduleGroup != NULL)
12904  {
12905  _Order_node_element = new _Non_greedy_node_source_type(*_M_pScheduleGroup, _Item, _Index);
12906  }
12907  else if (_M_pScheduler != NULL)
12908  {
12909  _Order_node_element = new _Non_greedy_node_source_type(*_M_pScheduler, _Item, _Index);
12910  }
12911  else
12912  {
12913  _Order_node_element = new _Non_greedy_node_source_type(_Item, _Index);
12914  }
12915  }
12916  else
12917  {
12918  typedef _Greedy_node<_Source_type<_Index>> _Greedy_node_source_type;
12919 
12920  if (_M_pScheduleGroup != NULL)
12921  {
12922  _Order_node_element = new _Greedy_node_source_type(*_M_pScheduleGroup, _Item, _Index);
12923  }
12924  else if (_M_pScheduler != NULL)
12925  {
12926  _Order_node_element = new _Greedy_node_source_type(*_M_pScheduler, _Item, _Index);
12927  }
12928  else
12929  {
12930  _Order_node_element = new _Greedy_node_source_type(_Item, _Index);
12931  }
12932  }
12933  _M_pSourceJoins[_Index] = _Order_node_element;
12934  _Order_node_element->link_target(_M_pJoinNode);
12935  _Initialize_joins<_Index + 1>();
12936  }
#define NULL
Definition: vcruntime.h:236
Non-greedy join messaging blocks postpone messages and try and consume them after all have arrived...
Definition: agents.h:9130
Scheduler * _M_pScheduler
Definition: agents.h:12981
_Type _M_sourceTuple
Definition: agents.h:12978
ScheduleGroup * _M_pScheduleGroup
Definition: agents.h:12984
_Join_node< _Type, _Destination_type, _Jtype > * _M_pJoinNode
Definition: agents.h:12975
void * _M_pSourceJoins[std::tuple_size< _Type >::value]
Definition: agents.h:12972
template<typename _Type , join_type _Jtype = non_greedy>
template<>
void Concurrency::multitype_join< _Type, _Jtype >::_Initialize_joins ( )
inlineprivate

Provides a sentinel template specialization for _Initialize_joins recursive template expansion.

12944  {
12945  }
template<typename _Type , join_type _Jtype = non_greedy>
virtual message<_Destination_type>* Concurrency::multitype_join< _Type, _Jtype >::accept ( runtime_object_identity  _MsgId,
_Inout_ ITarget< _Destination_type > *  _PTarget 
)
inlinevirtual

Accepts a message that was offered by this multitype_join block, transferring ownership to the caller.

Parameters
_MsgIdThe runtime_object_identity of the offered message object.
_PTargetA pointer to the target block that is calling the accept method.
Returns
A pointer to the message that the caller now has ownership of.
12781  {
12782  return _M_pJoinNode->accept(_MsgId, _PTarget);
12783  }
_Join_node< _Type, _Destination_type, _Jtype > * _M_pJoinNode
Definition: agents.h:12975
template<typename _Type , join_type _Jtype = non_greedy>
virtual void Concurrency::multitype_join< _Type, _Jtype >::acquire_ref ( _Inout_ ITarget< _Destination_type > *  _PTarget)
inlinevirtual

Acquires a reference count on this multitype_join messaging block, to prevent deletion.

Parameters
_PTargetA pointer to the target block that is calling this method.

This method is called by an ITarget object that is being linked to this source during the link_target method.

12859  {
12860  _M_pJoinNode->acquire_ref(_PTarget);
12861  }
_Join_node< _Type, _Destination_type, _Jtype > * _M_pJoinNode
Definition: agents.h:12975
template<typename _Type , join_type _Jtype = non_greedy>
virtual message<_Destination_type>* Concurrency::multitype_join< _Type, _Jtype >::consume ( runtime_object_identity  _MsgId,
_Inout_ ITarget< _Destination_type > *  _PTarget 
)
inlinevirtual

Consumes a message previously offered by the multitype_join messaging block and successfully reserved by the target, transferring ownership to the caller.

Parameters
_MsgIdThe runtime_object_identity of the reserved message object.
_PTargetA pointer to the target block that is calling the consume method.
Returns
A pointer to the message object that the caller now has ownership of.

The consume method is similar to accept, but must always be preceded by a call to reserve that returned true.

12828  {
12829  return _M_pJoinNode->consume(_MsgId, _PTarget);
12830  }
_Join_node< _Type, _Destination_type, _Jtype > * _M_pJoinNode
Definition: agents.h:12975
template<typename _Type , join_type _Jtype = non_greedy>
virtual void Concurrency::multitype_join< _Type, _Jtype >::link_target ( _Inout_ ITarget< _Destination_type > *  _PTarget)
inlinevirtual

Links a target block to this multitype_join messaging block.

Parameters
_PTargetA pointer to an ITarget block to link to this multitype_join messaging block.
12742  {
12743  _M_pJoinNode->link_target(_PTarget);
12744  }
_Join_node< _Type, _Destination_type, _Jtype > * _M_pJoinNode
Definition: agents.h:12975
template<typename _Type , join_type _Jtype = non_greedy>
multitype_join const& Concurrency::multitype_join< _Type, _Jtype >::operator= ( multitype_join< _Type, _Jtype > const &  )
private
template<typename _Type , join_type _Jtype = non_greedy>
virtual void Concurrency::multitype_join< _Type, _Jtype >::release ( runtime_object_identity  _MsgId,
_Inout_ ITarget< _Destination_type > *  _PTarget 
)
inlinevirtual

Releases a previous successful message reservation.

Parameters
_MsgIdThe runtime_object_identity of the message object being released.
_PTargetA pointer to the target block that is calling the release method.
12843  {
12844  _M_pJoinNode->release(_MsgId, _PTarget);
12845  }
_Join_node< _Type, _Destination_type, _Jtype > * _M_pJoinNode
Definition: agents.h:12975
template<typename _Type , join_type _Jtype = non_greedy>
virtual void Concurrency::multitype_join< _Type, _Jtype >::release_ref ( _Inout_ ITarget< _Destination_type > *  _PTarget)
inlinevirtual

Releases a reference count on this multiple_join messaging block.

Parameters
_PTargetA pointer to the target block that is calling this method.

This method is called by an ITarget object that is being unlinked from this source. The source block is allowed to release any resources reserved for the target block.

12875  {
12876  _M_pJoinNode->release_ref(_PTarget);
12877  }
_Join_node< _Type, _Destination_type, _Jtype > * _M_pJoinNode
Definition: agents.h:12975
template<typename _Type , join_type _Jtype = non_greedy>
virtual bool Concurrency::multitype_join< _Type, _Jtype >::reserve ( runtime_object_identity  _MsgId,
_Inout_ ITarget< _Destination_type > *  _PTarget 
)
inlinevirtual

Reserves a message previously offered by this multitype_join messaging block.

Parameters
_MsgIdThe runtime_object_identity of the message object being reserved.
_PTargetA pointer to the target block that is calling the reserve method.
Returns
true if the message was successfully reserved, false otherwise. Reservations can fail for many reasons, including: the message was already reserved or accepted by another target, the source could deny reservations, and so forth.

After you call reserve, if it succeeds, you must call either consume or release in order to take or give up possession of the message, respectively.

12805  {
12806  return _M_pJoinNode->reserve(_MsgId, _PTarget);
12807  }
_Join_node< _Type, _Destination_type, _Jtype > * _M_pJoinNode
Definition: agents.h:12975
template<typename _Type , join_type _Jtype = non_greedy>
virtual void Concurrency::multitype_join< _Type, _Jtype >::unlink_target ( _Inout_ ITarget< _Destination_type > *  _PTarget)
inlinevirtual

Unlinks a target block from this multitype_join messaging block.

Parameters
_PTargetA pointer to an ITarget block to unlink from this multitype_join messaging block.
12754  {
12755  _M_pJoinNode->unlink_target(_PTarget);
12756  }
_Join_node< _Type, _Destination_type, _Jtype > * _M_pJoinNode
Definition: agents.h:12975
template<typename _Type , join_type _Jtype = non_greedy>
virtual void Concurrency::multitype_join< _Type, _Jtype >::unlink_targets ( )
inlinevirtual

Unlinks all targets from this multitype_join messaging block.

Implements Concurrency::ISource< _Unwrap< _Type >::type >.

12763  {
12764  _M_pJoinNode->unlink_targets();
12765  }
_Join_node< _Type, _Destination_type, _Jtype > * _M_pJoinNode
Definition: agents.h:12975

Member Data Documentation

template<typename _Type , join_type _Jtype = non_greedy>
_Join_node<_Type, _Destination_type, _Jtype>* Concurrency::multitype_join< _Type, _Jtype >::_M_pJoinNode
private
template<typename _Type , join_type _Jtype = non_greedy>
ScheduleGroup* Concurrency::multitype_join< _Type, _Jtype >::_M_pScheduleGroup
private
template<typename _Type , join_type _Jtype = non_greedy>
Scheduler* Concurrency::multitype_join< _Type, _Jtype >::_M_pScheduler
private
template<typename _Type , join_type _Jtype = non_greedy>
void* Concurrency::multitype_join< _Type, _Jtype >::_M_pSourceJoins[std::tuple_size< _Type >::value]
private
template<typename _Type , join_type _Jtype = non_greedy>
_Type Concurrency::multitype_join< _Type, _Jtype >::_M_sourceTuple
private

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