• 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

0.0
/libs/full/components_base/src/generate_unique_ids.cpp
1
//  Copyright (c) 2007-2025 Hartmut Kaiser
2
//  Copyright (c) 2011      Bryce 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
#include <hpx/config.hpp>
9
#include <hpx/components_base/agas_interface.hpp>
10
#include <hpx/components_base/generate_unique_ids.hpp>
11
#include <hpx/modules/thread_support.hpp>
12

13
#include <algorithm>
14
#include <cstddef>
15
#include <mutex>
16

17
namespace hpx::util {
18

19
    naming::gid_type unique_id_ranges::get_id(std::size_t count)
×
20
    {
21
        // create a new id
22
        std::unique_lock l(mtx_);
×
23

24
        // ensure next_id doesn't overflow
25
        while (!lower_ || (lower_ + count) > upper_)
×
26
        {
27
            lower_ = naming::invalid_gid;
×
28

29
            naming::gid_type lower;
×
30
            std::size_t const count_ = (std::max) (range_delta, count);
×
31

32
            {
33
                hpx::unlock_guard ul(l);
34
                lower = hpx::agas::get_next_id(count_);
×
35
            }
36

37
            // we ignore the result if some other thread has already set the new
38
            // lower range
39
            if (!lower_)
40
            {
41
                lower_ = lower;
42
                upper_ = lower + count_;
×
43
            }
44
        }
45

46
        naming::gid_type result = lower_;
47
        lower_ += count;
48
        return result;
×
49
    }
50

51
    void unique_id_ranges::set_range(
52
        naming::gid_type const& lower, naming::gid_type const& upper)
53
    {
54
        std::lock_guard l(mtx_);
55
        lower_ = lower;
56
        upper_ = upper;
57
    }
58
}    // namespace hpx::util
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