• 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

57.5
/libs/core/algorithms/src/task_group.cpp
1
//  Copyright (c) 2021-2024 Hartmut Kaiser
2
//
3
//  SPDX-License-Identifier: BSL-1.0
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
#include <hpx/config.hpp>
8
#include <hpx/assert.hpp>
9
#include <hpx/modules/errors.hpp>
10
#include <hpx/modules/futures.hpp>
11
#include <hpx/modules/lcos_local.hpp>
12
#include <hpx/modules/serialization.hpp>
13
#include <hpx/parallel/task_group.hpp>
14

15
#include <exception>
16

17
namespace hpx::experimental {
18

19
    ///////////////////////////////////////////////////////////////////////////
20
    task_group::task_group()
2✔
21
      : latch_(1)
2✔
22
      , has_arrived_(false)
23
    {
2✔
24
    }
25

26
#if defined(HPX_DEBUG)
27
    task_group::~task_group()
2✔
28
    {
29
        // wait() must have been called
12✔
30
        HPX_ASSERT(latch_.is_ready());
31
    }
12✔
32
#else
33
    task_group::~task_group() = default;
2✔
34
#endif
35

12✔
36
    void task_group::wait()
37
    {
10✔
38
        bool expected = false;
10✔
39
        if (has_arrived_.compare_exchange_strong(expected, true))
40
        {
10✔
41
            latch_.arrive_and_wait();
10✔
42
            if (errors_.size() != 0)
43
            {
×
44
                throw errors_;
45
            }
×
46

×
47
            if (auto const state = HPX_MOVE(state_))
×
48
            {
49
                state->set_value(hpx::util::unused);
50
            }
51
        }
1✔
52
    }
53

1✔
54
    void task_group::add_exception(std::exception_ptr p)
55
    {
1✔
56
        errors_.add(HPX_MOVE(p));
57
    }
58

59
    void task_group::serialize(
60
        serialization::output_archive& ar, unsigned const)
61
    {
62
        if (!latch_.is_ready())
63
        {
64
            if (ar.is_preprocessing())
1✔
65
            {
66
                using init_no_addref = shared_state_type::init_no_addref;
67
                state_.reset(new shared_state_type(init_no_addref{}), false);
1✔
68
                preprocess_future(ar, *state_);
69
            }
1✔
70
            else
1✔
71
            {
72
                HPX_THROW_EXCEPTION(hpx::error::invalid_status,
1✔
73
                    "task_group::serialize",
1✔
74
                    "task_group must be ready in order for it to be "
75
                    "serialized");
×
76
            }
77
            return;
78
        }
1✔
79

80
        // the state is not needed anymore
×
81
        state_.reset();
82
    }
83
}    // namespace hpx::experimental
1✔
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