Turi Create  4.0
mps_command_queue.hpp
1 /* Copyright © 2019 Apple Inc. All rights reserved.
2  *
3  * Use of this source code is governed by a BSD-3-clause license that can
4  * be found in the LICENSE.txt file or at https://opensource.org/licenses/BSD-3-Clause
5  */
6 
7 #ifndef UNITY_TOOLKITS_NEURAL_NET_MPS_COMMAND_QUEUE_HPP_
8 #define UNITY_TOOLKITS_NEURAL_NET_MPS_COMMAND_QUEUE_HPP_
9 
10 // C++ headers and implementations can include this file for the forward
11 // declaration of mps_command_queue, allowing C++ code to pass mps_command_queue
12 // pointers and references. Objective C++ implementations can include this file
13 // to obtain the MTLCommandQueue that the mps_command_queue wraps.
14 
15 namespace turi {
16 namespace neural_net {
17 
18 // C++-only files just get this forward declaration.
19 struct mps_command_queue;
20 
21 } // namespace neural_net
22 } // namespace turi
23 
24 // Define the mps_command_queue struct for Objective C++ files.
25 #ifdef __OBJC__
26 
27 #import <Metal/Metal.h>
28 
29 NS_ASSUME_NONNULL_BEGIN
30 
31 namespace turi {
32 namespace neural_net {
33 
34 /**
35  * Simple wrapper around an MTLCommandQueue-conforming Objective C object, so
36  * that pure C++ code can pass these objects around.
37  */
38 struct mps_command_queue {
39  id <MTLCommandQueue> impl = nil;
40 };
41 
42 } // namespace neural_net
43 } // namespace turi
44 
45 NS_ASSUME_NONNULL_END
46 
47 #endif // __OBJC__
48 
49 #endif // UNITY_TOOLKITS_NEURAL_NET_MPS_COMMAND_QUEUE_HPP_