1 // Copyright (c) 2011 Vinay C Amatya 2 // Copyright (c) 2011 Bryce Lelbach 3 // 4 // Distributed under the Boost Software License, Version 1.0. (See accompanying 5 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 6 7 #if !defined(HPX_527D225B_F1EC_4BC5_9245_3A69C6AE5304) 8 #define HPX_527D225B_F1EC_4BC5_9245_3A69C6AE5304 9 10 #include <hpx/runtime.hpp> 11 #include <hpx/include/client.hpp> 12 13 #include <examples/nqueen/server/nqueen.hpp> 14 15 #include <cstddef> 16 #include <utility> 17 18 namespace nqueen 19 { 20 class board : public hpx::components::client_base<board, server::board> 21 { 22 typedef hpx::components::client_base<board, server::board> base_type; 23 24 public: board()25 board() {} board(hpx::id_type && gid)26 board(hpx::id_type&& gid) 27 : base_type(std::move(gid)) 28 { 29 } board(hpx::future<hpx::id_type> && gid)30 board(hpx::future<hpx::id_type>&& gid) 31 : base_type(std::move(gid)) 32 { 33 } 34 init_board(std::size_t size)35 void init_board(std::size_t size) 36 { 37 return init_board_async(size).get(); 38 } 39 init_board_async(std::size_t size)40 hpx::lcos::future<void> init_board_async(std::size_t size) 41 { 42 return hpx::async<server::board::init_action>(this->get_id(), size); 43 } 44 45 //------------------------------------------------------- access_board()46 list_type access_board() 47 { 48 return access_board_async().get(); 49 } 50 access_board_async()51 hpx::lcos::future<list_type> access_board_async() 52 { 53 typedef server::board::access_action action_type; 54 return hpx::async<action_type>(this->get_id()); 55 } 56 57 //------------------------------------------------------ update_board(std::size_t level,std::size_t pos)58 void update_board(std::size_t level, std::size_t pos) 59 { 60 hpx::apply<server::board::update_action>( 61 this->get_id(), level, pos); 62 } 63 64 //----------------------------------------------------- check_board(list_type const & list,std::size_t level)65 bool check_board(list_type const& list, std::size_t level) 66 { 67 return check_board_async(list, level).get(); 68 } 69 check_board_async(list_type const & list,std::size_t level)70 hpx::lcos::future<bool> check_board_async(list_type const& list, 71 std::size_t level) 72 { 73 typedef server::board::check_action action_type; 74 return hpx::async<action_type>(this->get_id(), list, level); 75 } 76 77 //--------------------------------------------------------- solve_board(list_type const & list,std::size_t size,std::size_t level,std::size_t col)78 std::size_t solve_board(list_type const& list, std::size_t size, 79 std::size_t level, std::size_t col) 80 { 81 return solve_board_async(list, size, level, col).get(); 82 } 83 solve_board_async(list_type const & list,std::size_t size,std::size_t level,std::size_t col)84 hpx::lcos::future<std::size_t> solve_board_async(list_type const& list, 85 std::size_t size, std::size_t level, std::size_t col) 86 { 87 typedef server::board::solve_action action_type; 88 return hpx::async<action_type>( 89 this->get_id(), list, size, level, col); 90 } 91 92 //--------------------------------------------------------- clear_board()93 void clear_board() 94 { 95 hpx::apply<server::board::clear_action>(this->get_id()); 96 } 97 }; 98 } 99 100 #endif // HPX_527D225B_F1EC_4BC5_9245_3A69C6AE5304 101 102