• 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

55.56
/libs/full/runtime_components/include/hpx/runtime_components/server/console_error_sink_singleton.hpp
1
//  Copyright (c) 2007-2021 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
#pragma once
9

10
#include <hpx/config.hpp>
11
#include <hpx/modules/concurrency.hpp>
12
#include <hpx/modules/functional.hpp>
13

14
#include <mutex>
15
#include <string>
16
#include <utility>
17

18
///////////////////////////////////////////////////////////////////////////////
19
namespace hpx { namespace components { namespace server {
20

21
    ///////////////////////////////////////////////////////////////////////////
22
    class console_error_dispatcher
32✔
23
    {
24
    public:
25
        HPX_NON_COPYABLE(console_error_dispatcher);
26

27
    public:
28
        typedef util::spinlock mutex_type;
29
        typedef hpx::function<void(std::string const&)> sink_type;
30

31
        console_error_dispatcher()
32
          : mtx_()
32✔
33
        {
34
        }
35

36
        template <typename F>
37
        sink_type set_error_sink(F&& sink)
32✔
38
        {
39
            std::lock_guard<mutex_type> l(mtx_);
32✔
40
            sink_type old_sink = HPX_MOVE(sink_);
41
            sink_ = HPX_FORWARD(F, sink);
42
            return old_sink;
32✔
43
        }
44

45
        void operator()(std::string const& msg)
×
46
        {
47
            std::lock_guard<mutex_type> l(mtx_);
×
48
            if (sink_)
×
49
                sink_(msg);
50
        }
×
51

52
    private:
53
        mutex_type mtx_;
54
        sink_type sink_;
55
    };
56

57
    ///////////////////////////////////////////////////////////////////////////
58
    HPX_EXPORT console_error_dispatcher& get_error_dispatcher();
59
}}}    // namespace hpx::components::server
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