Last active
February 1, 2021 18:32
-
-
Save tiagofgon/e7c1d809e25cabfc1275eb26bb505538 to your computer and use it in GitHub Desktop.
migrating issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <hpx/hpx.hpp> | |
#include <hpx/hpx_main.hpp> | |
#include <hpx/testing.hpp> | |
////////////////////////////////////////////////////////////////////////// | |
struct test_server: hpx::components::migration_support< hpx::components::component_base<test_server> > | |
{ | |
typedef hpx::components::migration_support< hpx::components::component_base<test_server> > base_type; | |
test_server(int data = 0) : data_(data) {} | |
~test_server() {} | |
int get_data() const | |
{ | |
return data_; | |
} | |
test_server(test_server const& rhs) | |
: base_type(rhs), data_(rhs.data_) | |
{} | |
test_server(test_server && rhs) | |
: base_type(std::move(rhs)), data_(rhs.data_) | |
{} | |
test_server& operator=(test_server const & rhs) | |
{ | |
data_ = rhs.data_; | |
return *this; | |
} | |
test_server& operator=(test_server && rhs) | |
{ | |
data_ = rhs.data_; | |
return *this; | |
} | |
HPX_DEFINE_COMPONENT_ACTION(test_server, get_data, get_data_action); | |
template <typename Archive> | |
void serialize(Archive& ar, unsigned version) | |
{ | |
ar & data_; | |
} | |
private: | |
int data_; | |
}; | |
typedef hpx::components::component<test_server> server_type; | |
HPX_REGISTER_COMPONENT(server_type, test_server); | |
typedef test_server::get_data_action get_data_action; | |
HPX_REGISTER_ACTION_DECLARATION(get_data_action); | |
HPX_REGISTER_ACTION(get_data_action); | |
int main() | |
{ | |
hpx::id_type t1 = hpx::new_<test_server>(hpx::find_here(), 42).get(); | |
std::shared_ptr<test_server> ptr = hpx::get_ptr<test_server>(hpx::launch::sync, t1); | |
std::cout << "get_data: " << ptr->get_data() << std::endl; | |
// migrate | |
std::vector<hpx::id_type> localities = hpx::find_remote_localities(); | |
hpx::components::migrate<test_server>(t1, localities[0]).get(); | |
// this will never print | |
std::cout << "Hello after migrating" << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment