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

STEllAR-GROUP / hpx / #856

28 Dec 2022 02:00AM UTC coverage: 86.602% (+0.05%) from 86.55%
#856

push

StellarBot
Merge #6119

6119: Update CMakeLists.txt r=hkaiser a=khuck

updating the default APEX version


Co-authored-by: Kevin Huck <khuck@cs.uoregon.edu>

174566 of 201573 relevant lines covered (86.6%)

1876093.78 hits per line

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

73.53
/libs/core/threading/tests/unit/stop_token_race2.cpp
1
//  Copyright (c) 2020 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
//  Parts of this code were inspired by https://github.com/josuttis/jthread. The
8
//  original code was published by Nicolai Josuttis and Lewis Baker under the
9
//  Creative Commons Attribution 4.0 International License
10
//  (http://creativecommons.org/licenses/by/4.0/).
11

12
#include <hpx/local/init.hpp>
13
#include <hpx/modules/testing.hpp>
14
#include <hpx/modules/threading.hpp>
15

16
#include <iostream>
17

18
///////////////////////////////////////////////////////////////////////////////
19
void test_callback_throw()
1✔
20
{
21
    // create stop_source
22
    hpx::stop_source ssrc;
1✔
23
    HPX_TEST(ssrc.stop_possible());
1✔
24
    HPX_TEST(!ssrc.stop_requested());
1✔
25

26
    // create stop_token from stop_source
27
    hpx::stop_token stok{ssrc.get_token()};
1✔
28
    HPX_TEST(ssrc.stop_possible());
1✔
29
    HPX_TEST(!ssrc.stop_requested());
1✔
30
    HPX_TEST(stok.stop_possible());
1✔
31
    HPX_TEST(!stok.stop_requested());
1✔
32

33
    // register callback
34
    bool cb1_called{false};
1✔
35
    bool cb2_called{false};
1✔
36

37
    auto cb = [&] {
2✔
38
        cb1_called = true;
×
39
        // throw
40
        throw "callback called";
×
41
    };
42

43
    hpx::stop_callback<decltype(cb)> cb1(stok, cb);
1✔
44

45
    HPX_TEST(ssrc.stop_possible());
1✔
46
    HPX_TEST(!ssrc.stop_requested());
1✔
47
    HPX_TEST(stok.stop_possible());
1✔
48
    HPX_TEST(!stok.stop_requested());
1✔
49
    HPX_TEST(!cb1_called);
1✔
50
    HPX_TEST(!cb2_called);
1✔
51

52
    // catch terminate() call:
53
    std::set_terminate([] {
3✔
54
        std::cout << "std::terminate called\n";
×
55
        std::exit(hpx::util::report_errors());
×
56
    });
57

58
    // request stop
59
    ssrc.request_stop();
×
60
    HPX_TEST(false);
×
61
}
×
62

63
///////////////////////////////////////////////////////////////////////////////
64
int hpx_main()
1✔
65
{
66
    // this test terminates execution
67
    test_callback_throw();
1✔
68

69
    return hpx::util::report_errors();
1✔
70
}
71

72
int main(int argc, char* argv[])
1✔
73
{
74
    HPX_TEST_EQ_MSG(hpx::local::init(hpx_main, argc, argv), 0,
1✔
75
        "HPX main exited with non-zero status");
76

77
    return hpx::util::report_errors();
×
78
}
×
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

© 2026 Coveralls, Inc