1    	// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2    	// vim: ts=8 sw=2 smarttab
3    	
4    	#ifndef CEPH_TRACEPOINT_PROVIDER_H
5    	#define CEPH_TRACEPOINT_PROVIDER_H
6    	
7    	#include "common/ceph_context.h"
8    	#include "common/config_obs.h"
9    	#include "common/ceph_mutex.h"
10   	#include <dlfcn.h>
11   	
12   	class TracepointProvider : public md_config_obs_t {
13   	public:
14   	  struct Traits {
15   	    const char *library;
16   	    const char *config_key;
17   	
18   	    Traits(const char *library, const char *config_key)
19   	      : library(library), config_key(config_key) {
20   	    }
21   	  };
22   	
23   	  class Singleton {
24   	  public:
25   	    Singleton(CephContext *cct, const char *library, const char *config_key)
26   	      : tracepoint_provider(new TracepointProvider(cct, library, config_key)) {
27   	    }
28   	    ~Singleton() {
29   	      delete tracepoint_provider;
30   	    }
31   	
32   	    inline bool is_enabled() const {
33   	      return tracepoint_provider->m_handle != nullptr;
34   	    }
35   	  private:
36   	    TracepointProvider *tracepoint_provider;
37   	  };
38   	
39   	  template <const Traits &traits>
40   	  class TypedSingleton : public Singleton {
41   	  public:
42   	    explicit TypedSingleton(CephContext *cct)
43   	      : Singleton(cct, traits.library, traits.config_key) {
44   	    }
45   	  };
46   	
47   	  TracepointProvider(CephContext *cct, const char *library,
48   	                     const char *config_key);
49   	  ~TracepointProvider() override;
50   	
51   	  TracepointProvider(const TracepointProvider&) = delete;
52   	  TracepointProvider operator =(const TracepointProvider&) = delete;
53   	  TracepointProvider(TracepointProvider&&) = delete;
54   	  TracepointProvider operator =(TracepointProvider&&) = delete;
55   	
56   	  template <const Traits &traits>
57   	  static void initialize(CephContext *cct) {
58   	#ifdef WITH_LTTNG
59   	     cct->lookup_or_create_singleton_object<TypedSingleton<traits>>(
(13) Event template_instantiation_context: instantiation of "T &CephContext::lookup_or_create_singleton_object<T,Args...>(std::string_view, bool, Args &&...) [with T=TracepointProvider::TypedSingleton<<unnamed>::tracepoint_traits>, Args=<CephContext *&>]" at line 60 of "/ceph/src/common/TracepointProvider.h"
Also see events: [no_matching_constructor][caretline][argument_list_types_add_on][compiler_generated_function_context][template_instantiation_context][template_instantiation_context][template_instantiation_context][template_instantiation_context][context_lines_skipped][template_instantiation_context][template_instantiation_context][template_instantiation_context][template_instantiation_context]
60   	       traits.library, false, cct);
61   	#endif
62   	  }
63   	
64   	protected:
65   	  const char** get_tracked_conf_keys() const override {
66   	    return m_config_keys;
67   	  }
68   	  void handle_conf_change(const ConfigProxy& conf,
69   				  const std::set <std::string> &changed) override;
70   	
71   	private:
72   	  CephContext *m_cct;
73   	  std::string m_library;
74   	  mutable const char* m_config_keys[2];
75   	
76   	  ceph::mutex m_lock = ceph::make_mutex("TracepointProvider::m_lock");
77   	  void* m_handle = nullptr;
78   	
79   	  void verify_config(const ConfigProxy& conf);
80   	};
81   	
82   	#endif // CEPH_TRACEPOINT_PROVIDER_H
83