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
12610  {
12611  _M_pJoinNode = new _Join_node<_Type, _Destination_type, _Jtype>();
12612  _Initialize_joins<0>();
12613  }
Scheduler * _M_pScheduler
Definition: agents.h:12983
_Type _M_sourceTuple
Definition: agents.h:12980
ScheduleGroup * _M_pScheduleGroup
Definition: agents.h:12986
_Join_node< _Type, _Destination_type, _Jtype > * _M_pJoinNode
Definition: agents.h:12977
#define NULL
Definition: corecrt.h:158
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
12698  {
12699  // Copy scheduler group or scheduler to the new object.
12700  _M_pScheduleGroup = _Join._M_pScheduleGroup;
12701  _M_pScheduler = _Join._M_pScheduler;
12702 
12703  // Single assignment is heap allocated, so simply copy the pointer. If it already has
12704  // a value, it will be preserved.
12705  _M_pJoinNode = _Join._M_pJoinNode;
12706  _Join._M_pJoinNode = NULL;
12707 
12708  // Invoke copy assignment for tuple to copy pointers to message blocks.
12709  _M_sourceTuple = _Join._M_sourceTuple;
12710 
12711  // Copy the pointers to order nodes to a new object and zero out in the old object.
12712  memcpy(_M_pSourceJoins, _Join._M_pSourceJoins, sizeof(_M_pSourceJoins));
12713  memset(_Join._M_pSourceJoins, 0, sizeof(_M_pSourceJoins));
12714  }
Scheduler * _M_pScheduler
Definition: agents.h:12983
_Type _M_sourceTuple
Definition: agents.h:12980
ScheduleGroup * _M_pScheduleGroup
Definition: agents.h:12986
_Join_node< _Type, _Destination_type, _Jtype > * _M_pJoinNode
Definition: agents.h:12977
memcpy(_Destination, _Source, _SourceSize)
void * _M_pSourceJoins[std::tuple_size< _Type >::value]
Definition: agents.h:12974
#define NULL
Definition: corecrt.h:158
template<typename _Type , join_type _Jtype = non_greedy>
Concurrency::multitype_join< _Type, _Jtype >::~multitype_join ( )
inline

Destroys the multitype_join messaging block.

12721  {
12722  delete _M_pJoinNode;
12723  _Delete_joins<0>();
12724  }
_Join_node< _Type, _Destination_type, _Jtype > * _M_pJoinNode
Definition: agents.h:12977
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
12958  {
12959  delete static_cast<_Order_node_base_source_type<_Index> *>(_M_pSourceJoins[_Index]);
12961  _Delete_joins<_Index + 1>();
12962  }
_In_ size_t _In_ int _Index
Definition: time.h:102
void * _M_pSourceJoins[std::tuple_size< _Type >::value]
Definition: agents.h:12974
#define NULL
Definition: corecrt.h:158
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.

12970  {
12971  }
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
12897  {
12898  std::tuple_element_t<_Index, _Type> _Item = std::get<_Index>(_M_sourceTuple);
12899  _Order_node_base_source_type<_Index> * _Order_node_element = NULL;
12900 
12901  if (_Jtype == non_greedy)
12902  {
12903  typedef _Non_greedy_node<_Source_type<_Index>> _Non_greedy_node_source_type;
12904 
12905  if (_M_pScheduleGroup != NULL)
12906  {
12907  _Order_node_element = new _Non_greedy_node_source_type(*_M_pScheduleGroup, _Item, _Index);
12908  }
12909  else if (_M_pScheduler != NULL)
12910  {
12911  _Order_node_element = new _Non_greedy_node_source_type(*_M_pScheduler, _Item, _Index);
12912  }
12913  else
12914  {
12915  _Order_node_element = new _Non_greedy_node_source_type(_Item, _Index);
12916  }
12917  }
12918  else
12919  {
12920  typedef _Greedy_node<_Source_type<_Index>> _Greedy_node_source_type;
12921 
12922  if (_M_pScheduleGroup != NULL)
12923  {
12924  _Order_node_element = new _Greedy_node_source_type(*_M_pScheduleGroup, _Item, _Index);
12925  }
12926  else if (_M_pScheduler != NULL)
12927  {
12928  _Order_node_element = new _Greedy_node_source_type(*_M_pScheduler, _Item, _Index);
12929  }
12930  else
12931  {
12932  _Order_node_element = new _Greedy_node_source_type(_Item, _Index);
12933  }
12934  }
12935  _M_pSourceJoins[_Index] = _Order_node_element;
12936  _Order_node_element->link_target(_M_pJoinNode);
12937  _Initialize_joins<_Index + 1>();
12938  }
Non-greedy join messaging blocks postpone messages and try and consume them after all have arrived...
Definition: agents.h:9132
Scheduler * _M_pScheduler
Definition: agents.h:12983
_Type _M_sourceTuple
Definition: agents.h:12980
_In_ size_t _In_ int _Index
Definition: time.h:102
ScheduleGroup * _M_pScheduleGroup
Definition: agents.h:12986
_Join_node< _Type, _Destination_type, _Jtype > * _M_pJoinNode
Definition: agents.h:12977
void * _M_pSourceJoins[std::tuple_size< _Type >::value]
Definition: agents.h:12974
#define NULL
Definition: corecrt.h:158
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.

12946  {
12947  }
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.
12783  {
12784  return _M_pJoinNode->accept(_MsgId, _PTarget);
12785  }
_Join_node< _Type, _Destination_type, _Jtype > * _M_pJoinNode
Definition: agents.h:12977
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.

12861  {
12862  _M_pJoinNode->acquire_ref(_PTarget);
12863  }
_Join_node< _Type, _Destination_type, _Jtype > * _M_pJoinNode
Definition: agents.h:12977
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.

12830  {
12831  return _M_pJoinNode->consume(_MsgId, _PTarget);
12832  }
_Join_node< _Type, _Destination_type, _Jtype > * _M_pJoinNode
Definition: agents.h:12977
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.
12744  {
12745  _M_pJoinNode->link_target(_PTarget);
12746  }
_Join_node< _Type, _Destination_type, _Jtype > * _M_pJoinNode
Definition: agents.h:12977
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.
12845  {
12846  _M_pJoinNode->release(_MsgId, _PTarget);
12847  }
_Join_node< _Type, _Destination_type, _Jtype > * _M_pJoinNode
Definition: agents.h:12977
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.

12877  {
12878  _M_pJoinNode->release_ref(_PTarget);
12879  }
_Join_node< _Type, _Destination_type, _Jtype > * _M_pJoinNode
Definition: agents.h:12977
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.

12807  {
12808  return _M_pJoinNode->reserve(_MsgId, _PTarget);
12809  }
_Join_node< _Type, _Destination_type, _Jtype > * _M_pJoinNode
Definition: agents.h:12977
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.
12756  {
12757  _M_pJoinNode->unlink_target(_PTarget);
12758  }
_Join_node< _Type, _Destination_type, _Jtype > * _M_pJoinNode
Definition: agents.h:12977
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 >.

12765  {
12766  _M_pJoinNode->unlink_targets();
12767  }
_Join_node< _Type, _Destination_type, _Jtype > * _M_pJoinNode
Definition: agents.h:12977

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: