helics 3.7.0
Loading...
Searching...
No Matches
ZmqContextManager.h
1/*
2Copyright (c) 2017-2026,
3Battelle Memorial Institute; Lawrence Livermore National Security, LLC; Alliance for Energy
4Innovation LLC. See the top-level NOTICE for additional details. All rights reserved.
5SPDX-License-Identifier: BSD-3-Clause
6*/
7
8/*
9 * LLNS Copyright Start
10 * Copyright (c) 2017, Lawrence Livermore National Security
11 * This work was performed under the auspices of the U.S. Department
12 * of Energy by Lawrence Livermore National Laboratory in part under
13 * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
14 * Produced at the Lawrence Livermore National Laboratory.
15 * All rights reserved.
16 * For details, see the LICENSE file.
17 * LLNS Copyright End
18 */
19#pragma once
20
21#include <atomic>
22#include <map>
23#include <memory>
24#include <string>
25namespace zmq {
26class context_t;
27} // namespace zmq
28
33 private:
34 static std::map<std::string, std::shared_ptr<ZmqContextManager>>
35 contexts;
36 std::string name;
37 std::unique_ptr<zmq::context_t> zcontext;
38 std::atomic<bool> leakOnDelete{true};
40
42 explicit ZmqContextManager(const std::string& contextName);
43
44 public:
46 static std::shared_ptr<ZmqContextManager>
47 getContextPointer(const std::string& contextName = std::string{});
49 static zmq::context_t& getContext(const std::string& contextName = std::string{});
51 static void startContext(const std::string& contextName = std::string{});
53 static void closeContext(const std::string& contextName = std::string{});
64 static bool setContextToLeakOnDelete(const std::string& contextName = std::string{});
66 static bool setContextToNotLeakOnDelete(const std::string& contextName = std::string{});
70 const std::string& getName() const { return name; }
72 zmq::context_t& getBaseContext() const { return *zcontext; }
73};
Definition ZmqContextManager.h:32
static bool setContextToNotLeakOnDelete(const std::string &contextName=std::string{})
Definition ZmqContextManager.cpp:89
static void closeContext(const std::string &contextName=std::string{})
Definition ZmqContextManager.cpp:70
zmq::context_t & getBaseContext() const
Definition ZmqContextManager.h:72
~ZmqContextManager()
Definition ZmqContextManager.cpp:98
static bool setContextToLeakOnDelete(const std::string &contextName=std::string{})
Definition ZmqContextManager.cpp:79
static zmq::context_t & getContext(const std::string &contextName=std::string{})
Definition ZmqContextManager.cpp:55
const std::string & getName() const
Definition ZmqContextManager.h:70
static std::shared_ptr< ZmqContextManager > getContextPointer(const std::string &contextName=std::string{})
Definition ZmqContextManager.cpp:39
static void startContext(const std::string &contextName=std::string{})
Definition ZmqContextManager.cpp:60