carton_runner_interface/
lib.rs

1// Copyright 2023 Vivek Panyam
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! This crate contains the interface between a runner and the core library
16//! It is very important that no backward-incompatible changes are made within one major version of the runner interface
17//!
18//! Each runner is built against one version of this crate.
19//! The core library is built against *all* major versions of this crate
20
21macro_rules! if_wasm {
22    ($($item:item)*) => {$(
23        #[cfg(target_family = "wasm")]
24        $item
25    )*}
26}
27
28macro_rules! if_not_wasm {
29    ($($item:item)*) => {$(
30        #[cfg(not(target_family = "wasm"))]
31        $item
32    )*}
33}
34
35mod client;
36mod do_not_modify;
37mod multiplexer;
38pub mod runner;
39
40if_not_wasm! {
41    pub mod server;
42    pub mod slowlog;
43}
44
45if_not_wasm! {
46    pub(crate) use tokio::spawn as do_spawn;
47
48    /// `Send` if not on wasm
49    pub(crate) use Send as MaybeSend;
50}
51
52if_wasm! {
53    pub(crate) use tokio::task::spawn_local as do_spawn;
54
55    /// `Send` if not on wasm
56    pub(crate) trait MaybeSend {}
57    impl <T> MaybeSend for T {}
58}
59
60pub use do_not_modify::types;
61pub use runner::Runner;
62
63#[cfg(feature = "benchmark")]
64pub mod _only_public_for_benchmarks_do_not_use {
65    pub use crate::do_not_modify::alloc::TypedAlloc;
66    pub use crate::do_not_modify::alloc_inline::{
67        alloc_tensor as alloc_tensor_inline, alloc_tensor_no_pool as alloc_tensor_no_pool_inline,
68        InlineAllocator, InlineTensorStorage,
69    };
70
71    pub use crate::do_not_modify::alloc_shm::{
72        alloc_tensor as alloc_tensor_shm, alloc_tensor_no_pool as alloc_tensor_no_pool_shm,
73        SHMAllocator, SHMTensorStorage,
74    };
75}