• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

STEllAR-GROUP / hpx / #882

31 Aug 2023 07:44PM UTC coverage: 41.798% (-44.7%) from 86.546%
#882

push

19442 of 46514 relevant lines covered (41.8%)

126375.38 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

89.47
/examples/quickstart/component_ctors.cpp
1
////////////////////////////////////////////////////////////////////////////////
2
//  Copyright (c) 2012 Bryce Adelstein-Lelbach
3
//
4
//  SPDX-License-Identifier: BSL-1.0
5
//  Distributed under the Boost Software License, Version 1.0. (See accompanying
6
//  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7
///////////////////////////////////////////////////////////////////////////////
8

9
#include <hpx/config.hpp>
10
#if !defined(HPX_COMPUTE_DEVICE_CODE)
11
#include <hpx/hpx_main.hpp>
12
#include <hpx/include/actions.hpp>
13
#include <hpx/include/components.hpp>
14
#include <hpx/iostream.hpp>
15

16
#include <string>
17
#include <utility>
18

19
using hpx::components::client_base;
20
using hpx::components::component;
21
using hpx::components::component_base;
22

23
using hpx::async;
24
using hpx::find_here;
25
using hpx::id_type;
26

27
using hpx::cout;
28

29
struct message_server : component_base<message_server>
1✔
30
{
31
    std::string msg;
32

33
    message_server()
34
      : msg("uninitialized\n")
35
    {
36
    }
37

38
    message_server(std::string const& msg_)
1✔
39
      : msg(msg_)
1✔
40
    {
41
    }
1✔
42

43
    void print() const
1✔
44
    {
45
        cout << msg << std::flush;
1✔
46
    }
1✔
47

48
    HPX_DEFINE_COMPONENT_ACTION(message_server, print, print_action)
49
};
50

51
typedef component<message_server> server_type;
52
HPX_REGISTER_COMPONENT(server_type, message_server)
5✔
53

54
typedef message_server::print_action print_action;
55
HPX_REGISTER_ACTION_DECLARATION(print_action)
56
HPX_REGISTER_ACTION(print_action)
×
57

58
struct message : client_base<message, message_server>
1✔
59
{
60
    typedef client_base<message, message_server> base_type;
61

62
    explicit message(hpx::id_type const& id)
63
      : base_type(id)
1✔
64
    {
65
    }
66

67
    message(hpx::future<hpx::id_type>&& id)
68
      : base_type(std::move(id))
×
69
    {
70
    }
71

72
    void print()
1✔
73
    {
74
        async<print_action>(this->get_id()).get();
2✔
75
    }
1✔
76
};
77

78
///////////////////////////////////////////////////////////////////////////////
79
int main()
1✔
80
{
81
    std::string msg = "hello world\n";
1✔
82
    message ms = hpx::new_<message>(hpx::find_here(), msg);
1✔
83

84
    ms.print();
1✔
85

86
    return 0;
87
}
88

89
#endif
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc