Skip to content

Commit

Permalink
Merge pull request #1913 from atrantan/master
Browse files Browse the repository at this point in the history
Add utility member functions for partitioned_vector
  • Loading branch information
hkaiser committed Dec 15, 2015
2 parents 8747446 + 4bfe47d commit f9c8d7b
Showing 1 changed file with 36 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@ namespace hpx { namespace server
components::simple_component_base<partitioned_vector<T> > >
base_type;

private:
data_type partition_vector_;

public:
///////////////////////////////////////////////////////////////////////
// Constructors
///////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -119,6 +117,12 @@ namespace hpx { namespace server
return partition_vector_;
}

/// Duplicate the copy method for action naming
data_type get_copied_data() const
{
return partition_vector_;
}

///////////////////////////////////////////////////////////////////////
iterator_type begin()
{
Expand Down Expand Up @@ -361,6 +365,7 @@ namespace hpx { namespace server
HPX_DEFINE_COMPONENT_DIRECT_ACTION(partitioned_vector, set_values);

// HPX_DEFINE_COMPONENT_ACTION(partition_vector, clear);
HPX_DEFINE_COMPONENT_DIRECT_ACTION(partitioned_vector, get_copied_data);
};
}}

Expand Down Expand Up @@ -396,6 +401,9 @@ namespace hpx { namespace server
HPX_REGISTER_ACTION_DECLARATION( \
hpx::server::partitioned_vector<type>::resize_action, \
BOOST_PP_CAT(__vector_resize_action_, name)); \
HPX_REGISTER_ACTION_DECLARATION( \
hpx::server::partitioned_vector<type>::get_copied_data_action, \
BOOST_PP_CAT(__vector_get_copied_data_action_, name)); \
/**/

#define HPX_REGISTER_PARTITIONED_VECTOR(...) \
Expand Down Expand Up @@ -429,6 +437,9 @@ namespace hpx { namespace server
HPX_REGISTER_ACTION( \
hpx::server::partitioned_vector<type>::resize_action, \
BOOST_PP_CAT(__vector_resize_action_, name)); \
HPX_REGISTER_ACTION( \
hpx::server::partitioned_vector<type>::get_copied_data_action, \
BOOST_PP_CAT(__vector_get_copied_data_action_, name)); \
typedef ::hpx::components::simple_component< \
::hpx::server::partitioned_vector<type> \
> BOOST_PP_CAT(__vector_, name); \
Expand All @@ -449,7 +460,6 @@ namespace hpx
typedef hpx::components::client_base<
partition_vector<T>, server::partitioned_vector<T>
> base_type;

public:
partition_vector() {}

Expand Down Expand Up @@ -716,7 +726,29 @@ namespace hpx
// HPX_ASSERT(this->get_id());
// this->base_type::clear_async(this->get_id()).get();
// }
};

/// Returns a copy of the data owned by the partition_vector
/// component.
///
/// \return This returns the data of the partition_vector
///
auto get_copied_data_sync()
{
return get_copied_data().get();
}

/// Returns a copy of the data owned by the partition_vector
/// component.
///
/// \return This returns the data as an hpx::future
///
auto get_copied_data() const
{
HPX_ASSERT(this->get_id());
return hpx::async<typename server_type::get_copied_data_action>(
this->get_id());
}
};
}

#endif

0 comments on commit f9c8d7b

Please sign in to comment.