|
| 1 | +//===- ResourceManager.h -- Interface for JIT resource managers -*- C++ -*-===// |
| 2 | +// |
| 3 | +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | +// See https://llvm.org/LICENSE.txt for license information. |
| 5 | +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | +// |
| 7 | +//===----------------------------------------------------------------------===// |
| 8 | +// |
| 9 | +// ResourceManager class and related APIs. |
| 10 | +// |
| 11 | +//===----------------------------------------------------------------------===// |
| 12 | + |
| 13 | +#ifndef ORC_RT_RESOURCEMANAGER_H |
| 14 | +#define ORC_RT_RESOURCEMANAGER_H |
| 15 | + |
| 16 | +#include "orc-rt/Error.h" |
| 17 | +#include "orc-rt/move_only_function.h" |
| 18 | + |
| 19 | +namespace orc_rt { |
| 20 | + |
| 21 | +/// A ResourceManager manages resources (e.g. JIT'd memory) to support a JIT |
| 22 | +/// session. |
| 23 | +class ResourceManager { |
| 24 | +public: |
| 25 | + using OnCompleteFn = move_only_function<void(Error)>; |
| 26 | + |
| 27 | + virtual ~ResourceManager(); |
| 28 | + |
| 29 | + /// The detach method will be called if the controller disconnects from the |
| 30 | + /// session without shutting the session down. |
| 31 | + /// |
| 32 | + /// Since no further requests for allocation will be made, the ResourceManager |
| 33 | + /// may discard any book-keeping data-structures used to support allocation. |
| 34 | + /// E.g. a JIT memory manager may discard its free-list, since no further |
| 35 | + /// JIT'd allocations will happen. |
| 36 | + virtual void detach(OnCompleteFn OnComplete) = 0; |
| 37 | + |
| 38 | + /// The shutdown operation will be called at the end of the session. |
| 39 | + /// The ResourceManager should release all held resources. |
| 40 | + virtual void shutdown(OnCompleteFn OnComplete) = 0; |
| 41 | +}; |
| 42 | +} // namespace orc_rt |
| 43 | + |
| 44 | +#endif // ORC_RT_RESOURCEMANAGER_H |
0 commit comments