TVM  0.9.4
Source.h
Go to the documentation of this file.
1 
3 #pragma once
4 
5 #include <tvm/api.h>
6 #include <tvm/event/enums.h>
7 
8 #include <map>
9 #include <memory>
10 #include <vector>
11 
12 namespace tvm
13 {
14 
15 namespace event
16 {
17 
18 class Listener;
19 
20 /* todo or to consider:
21  - delayed notify in case the same notification might be issue several time in a row
22  (for example, several contacts are added/remove at several point in the code)
23  - time-stamped events or lazy processing, so that a same event arriving by two
24  different way to a listener is not processed twice.*/
25 
27 {
28 public:
29  virtual ~Source() = default;
30 
31  void regist(std::shared_ptr<Listener> user, Type evt);
32  void notify(Type evt);
33 
34 private:
39  std::map<Type, std::vector<std::weak_ptr<Listener>>> registrations_;
40 };
41 
42 } // namespace event
43 
44 } // namespace tvm
#define TVM_DLLAPI
Definition: api.h:35
Definition: Source.h:27
void notify(Type evt)
virtual ~Source()=default
void regist(std::shared_ptr< Listener > user, Type evt)
Type
Definition: enums.h:12
Definition: Clock.h:12