FairMQ  1.4.14
C++ Message Queuing Library and Framework
PMIxPlugin.h
1 /********************************************************************************
2  * Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
3  * *
4  * This software is distributed under the terms of the *
5  * GNU Lesser General Public Licence (LGPL) version 3, *
6  * copied verbatim in the file "LICENSE" *
7  ********************************************************************************/
8 
9 #ifndef FAIR_MQ_PLUGINS_PMIX
10 #define FAIR_MQ_PLUGINS_PMIX
11 
12 #include "PMIx.hpp"
13 #include "PMIxCommands.h"
14 
15 #include <fairmq/Plugin.h>
16 #include <fairmq/Version.h>
17 #include <FairMQLogger.h>
18 
19 #include <string>
20 #include <sstream>
21 #include <stdexcept>
22 #include <string>
23 #include <sys/types.h>
24 #include <unistd.h>
25 #include <vector>
26 
27 namespace fair
28 {
29 namespace mq
30 {
31 namespace plugins
32 {
33 
34 class PMIxPlugin : public Plugin
35 {
36  public:
37  PMIxPlugin(const std::string& name,
38  const Plugin::Version version,
39  const std::string& maintainer,
40  const std::string& homepage,
41  PluginServices* pluginServices);
42  ~PMIxPlugin();
43 
44  auto PMIxClient() const -> std::string { return fPMIxClient; };
45 
46  private:
47  pmix::proc fProcess;
48  pid_t fPid;
49  std::string fPMIxClient;
50  std::string fDeviceId;
51  pmix::Commands fCommands;
52 
53  std::set<uint32_t> fStateChangeSubscribers;
54  uint32_t fLastExternalController;
55  bool fExitingAckedByLastExternalController;
56  std::condition_variable fExitingAcked;
57  std::mutex fStateChangeSubscriberMutex;
58 
59  DeviceState fCurrentState;
60  DeviceState fLastState;
61 
62  auto Init() -> pmix::proc;
63  auto Publish() -> void;
64  auto Fence() -> void;
65  auto Fence(const std::string& label) -> void;
66  auto Lookup() -> void;
67 
68  auto SubscribeForCommands() -> void;
69  auto WaitForExitingAck() -> void;
70 };
71 
72 Plugin::ProgOptions PMIxProgramOptions()
73 {
74  boost::program_options::options_description options("PMIx Plugin");
75  options.add_options()
76  ("pmix-dummy", boost::program_options::value<int>()->default_value(0), "Dummy.");
77  return options;
78 }
79 
80 REGISTER_FAIRMQ_PLUGIN(
81  PMIxPlugin, // Class name
82  pmix, // Plugin name (string, lower case chars only)
83  (Plugin::Version{FAIRMQ_VERSION_MAJOR,
84  FAIRMQ_VERSION_MINOR,
85  FAIRMQ_VERSION_PATCH}), // Version
86  "FairRootGroup <fairroot@gsi.de>", // Maintainer
87  "https://github.com/FairRootGroup/FairMQ", // Homepage
88  PMIxProgramOptions // custom program options for the plugin
89 )
90 
91 } /* namespace plugins */
92 } /* namespace mq */
93 } /* namespace fair */
94 
95 #endif /* FAIR_MQ_PLUGINS_PMIX */
Facilitates communication between devices and plugins.
Definition: PluginServices.h:40
Base class for FairMQ plugins.
Definition: Plugin.h:39
Definition: PMIx.hpp:26
Definition: PMIx.hpp:61
Definition: PMIxCommands.h:82
Tools for interfacing containers to the transport via polymorphic allocators.
Definition: DeviceRunner.h:23
Definition: PMIxPlugin.h:34
Definition: Version.h:22

privacy