"docker/vscode:/vscode.git/clone" did not exist on "ea40933f36038d61ecf6278b8019030291a67842"
resource_manager.h 1.03 KB
Newer Older
1
2
3
4
5
6
7
8
9
/*!
 *  Copyright (c) 2020 by Contributors
 * \file resource_manager.h
 * \brief Manage the resources in the runtime system.
 */
#ifndef DGL_RUNTIME_RESOURCE_MANAGER_H_
#define DGL_RUNTIME_RESOURCE_MANAGER_H_

#include <memory>
10
11
#include <string>
#include <unordered_map>
12
13
14
15
16

namespace dgl {
namespace runtime {

/*
17
18
19
20
21
 * A class that provides the interface to describe a resource that can be
 * managed by a resource manager. Some of the resources cannot be free'd
 * automatically when the process exits, especially when the process doesn't
 * exit normally. One example is shared memory. We can keep track of this kind
 * of resources and manage them properly.
22
23
24
 */
class Resource {
 public:
25
  virtual ~Resource() {}
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42

  virtual void Destroy() = 0;
};

// Add resource.
void AddResource(const std::string &key, std::shared_ptr<Resource> resource);

// Delete resource.
void DeleteResource(const std::string &key);

// Clean up all resources.
void CleanupResources();

}  // namespace runtime
}  // namespace dgl

#endif  // DGL_RUNTIME_RESOURCE_MANAGER_H_