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

HDFGroup / hermes / 4851036339

pending completion
4851036339

Pull #515

github

GitHub
Merge aee741046 into 87672e106
Pull Request #515: v1.0

5501 of 5501 new or added lines in 117 files covered. (100.0%)

4997 of 7299 relevant lines covered (68.46%)

6131966.73 hits per line

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

91.67
/src/thread_manager.h
1
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2
* Distributed under BSD 3-Clause license.                                   *
3
* Copyright by The HDF Group.                                               *
4
* Copyright by the Illinois Institute of Technology.                        *
5
* All rights reserved.                                                      *
6
*                                                                           *
7
* This file is part of Hermes. The full Hermes copyright notice, including  *
8
* terms governing use, modification, and redistribution, is contained in    *
9
* the COPYING file, which can be found at the top directory. If you do not  *
10
* have access to the file, you may request a copy from help@hdfgroup.org.   *
11
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
12

13
#ifndef HERMES_SRC_THREAD_MANAGER_H_
14
#define HERMES_SRC_THREAD_MANAGER_H_
15

16
#include "hermes_types.h"
17
#include <thallium.hpp>
18
#include <future>
19

20
namespace hermes {
21

22
class ThreadManager {
23
 public:
24
  ABT_xstream execution_stream_;      /**< Argobots execution stream */
25
  std::atomic<bool> kill_requested_;  /**< Terminate threads spawned here */
26

27
 public:
28
  /** Default constructor */
29
  ThreadManager() : kill_requested_(false) {
105✔
30
    int ret = ABT_xstream_create(ABT_SCHED_NULL, &execution_stream_);
105✔
31
    if (ret != ABT_SUCCESS) {
105✔
32
      HELOG(kFatal, "Could not create argobots xstream");
×
33
    }
34
  }
105✔
35

36
  /** Spawn a for handling a function or lambda */
37
  template<typename FuncT, typename ParamsT = void>
38
  void Spawn(FuncT &&func, ParamsT *params = nullptr) {
39
    int ret = ABT_thread_create_on_xstream(execution_stream_,
40
                                 func, (void*)params,
41
                                 ABT_THREAD_ATTR_NULL, NULL);
42
    if (ret != ABT_SUCCESS) {
43
      HELOG(kFatal, "Couldn't spawn worker");
44
    }
45
  }
46

47
  /** Begin terminating threads */
48
  void Join() {
105✔
49
    kill_requested_.store(true);
105✔
50
    ABT_xstream_join(execution_stream_);
105✔
51
    ABT_xstream_free(&execution_stream_);
105✔
52
  }
105✔
53

54
  /** Whether the threads in this thread manager should still be executing */
55
  bool Alive() {
487✔
56
    return !kill_requested_.load();
487✔
57
  }
58
};
59

60
}  // namespace hermes
61

62
#define HERMES_THREAD_MANAGER \
63
  hshm::EasySingleton<hermes::ThreadManager>::GetInstance()
64

65
#endif  // HERMES_SRC_THREAD_MANAGER_H_
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