reactive_mutiny/prelude/
advanced.rs

1//! Extra type aliases & internal types re-exports to allow advanced usage of the `reactive-mutiny` library.\
2//! For simple usage, see [crate::prelude].
3//!
4//! See `all-channels` example.
5
6pub use crate::{
7    prelude::*,
8    types::{FullDuplexUniChannel, FullDuplexMultiChannel},
9    ogre_std::ogre_alloc::{
10        BoundedOgreAllocator,
11        ogre_arc::OgreArc,
12        ogre_unique::OgreUnique,
13    }
14};
15use crate::{
16    multi,
17    uni,
18    ogre_std::{
19        ogre_queues,
20        ogre_alloc,
21    },
22};
23use std::sync::Arc;
24
25
26// allocators
27pub type AllocatorAtomicArray  <InType, const BUFFER_SIZE: usize> = ogre_alloc::ogre_array_pool_allocator::OgreArrayPoolAllocator<InType, ogre_queues::atomic::atomic_move::AtomicMove        <u32, BUFFER_SIZE>, BUFFER_SIZE>;
28pub type AllocatorFullSyncArray<InType, const BUFFER_SIZE: usize> = ogre_alloc::ogre_array_pool_allocator::OgreArrayPoolAllocator<InType, ogre_queues::full_sync::full_sync_move::FullSyncMove<u32, BUFFER_SIZE>, BUFFER_SIZE>;
29// TODO: pub type AllocatorBox                                             = ogre_alloc::ogre_box_allocator::OgreBoxAllocator;
30//       (Simply uses the Rust's default allocator. Usually, it is slower, is subjected to false-sharing performance degradation and, when used for event payloads, several allocation/deallocations may scatter the free space a little bit,
31//        but it has the advantage of not requiring any pre-allocation. So, there are legitimate use cases for this one here. For more info, look at the benchmarks).
32
33// Uni channels
34pub type ChannelUniMoveAtomic      <InType, const BUFFER_SIZE: usize, const MAX_STREAMS: usize> = uni::channels::movable::atomic::Atomic       <'static, InType, BUFFER_SIZE, MAX_STREAMS>;
35pub type ChannelUniMoveCrossbeam   <InType, const BUFFER_SIZE: usize, const MAX_STREAMS: usize> = uni::channels::movable::crossbeam::Crossbeam <'static, InType, BUFFER_SIZE, MAX_STREAMS>;
36pub type ChannelUniMoveFullSync    <InType, const BUFFER_SIZE: usize, const MAX_STREAMS: usize> = uni::channels::movable::full_sync::FullSync  <'static, InType, BUFFER_SIZE, MAX_STREAMS>;
37pub type ChannelUniZeroCopyAtomic  <InType, const BUFFER_SIZE: usize, const MAX_STREAMS: usize> = uni::channels::zero_copy::atomic::Atomic     <'static, InType, AllocatorAtomicArray  <InType, BUFFER_SIZE>, BUFFER_SIZE, MAX_STREAMS>;
38pub type ChannelUniZeroCopyFullSync<InType, const BUFFER_SIZE: usize, const MAX_STREAMS: usize> = uni::channels::zero_copy::full_sync::FullSync<'static, InType, AllocatorFullSyncArray<InType, BUFFER_SIZE>, BUFFER_SIZE, MAX_STREAMS>;
39
40// Unis
41pub type UniMoveAtomic<InType,
42                       const BUFFER_SIZE: usize,
43                       const MAX_STREAMS: usize = 1,
44                       const INSTRUMENTS: usize = {Instruments::LogsWithMetrics.into()}>
45    = uni::Uni<InType, ChannelUniMoveAtomic<InType, BUFFER_SIZE, MAX_STREAMS>, INSTRUMENTS, InType>;
46pub type UniMoveCrossbeam<InType,
47                          const BUFFER_SIZE: usize,
48                          const MAX_STREAMS: usize = 1,
49                          const INSTRUMENTS: usize = {Instruments::LogsWithMetrics.into()}>
50    = uni::Uni<InType, ChannelUniMoveCrossbeam<InType, BUFFER_SIZE, MAX_STREAMS>, INSTRUMENTS, InType>;
51pub type UniMoveFullSync<InType,
52                         const BUFFER_SIZE: usize,
53                         const MAX_STREAMS: usize = 1,
54                         const INSTRUMENTS: usize = {Instruments::LogsWithMetrics.into()}>
55    = uni::Uni<InType, ChannelUniMoveFullSync<InType, BUFFER_SIZE, MAX_STREAMS>, INSTRUMENTS, InType>;
56pub type UniZeroCopyAtomic<InType,
57                     const BUFFER_SIZE: usize,
58                     const MAX_STREAMS: usize = 1,
59                     const INSTRUMENTS: usize = {Instruments::LogsWithMetrics.into()}>
60    = uni::Uni<InType, ChannelUniZeroCopyAtomic<InType, BUFFER_SIZE, MAX_STREAMS>, INSTRUMENTS, OgreUnique<InType, AllocatorAtomicArray<InType, BUFFER_SIZE>>>;
61pub type UniZeroCopyFullSync<InType,
62                             const BUFFER_SIZE: usize,
63                             const MAX_STREAMS: usize = 1,
64                             const INSTRUMENTS: usize = {Instruments::LogsWithMetrics.into()}>
65    = uni::Uni<InType, ChannelUniZeroCopyFullSync<InType, BUFFER_SIZE, MAX_STREAMS>, INSTRUMENTS, OgreUnique<InType, AllocatorFullSyncArray<InType, BUFFER_SIZE>>>;
66
67
68// Multi channels
69pub type ChannelMultiArcAtomic      <ItemType, const BUFFER_SIZE: usize, const MAX_STREAMS: usize> = multi::channels::arc::atomic::Atomic          <'static, ItemType, BUFFER_SIZE, MAX_STREAMS>;
70pub type ChannelMultiArcCrossbeam   <ItemType, const BUFFER_SIZE: usize, const MAX_STREAMS: usize> = multi::channels::arc::crossbeam::Crossbeam    <'static, ItemType, BUFFER_SIZE, MAX_STREAMS>;
71pub type ChannelMultiArcFullSync    <ItemType, const BUFFER_SIZE: usize, const MAX_STREAMS: usize> = multi::channels::arc::full_sync::FullSync     <'static, ItemType, BUFFER_SIZE, MAX_STREAMS>;
72pub type ChannelMultiOgreArcAtomic  <ItemType, const BUFFER_SIZE: usize, const MAX_STREAMS: usize> = multi::channels::ogre_arc::atomic::Atomic     <'static, ItemType, AllocatorAtomicArray<ItemType, BUFFER_SIZE>, BUFFER_SIZE, MAX_STREAMS>;
73pub type ChannelMultiOgreArcFullSync<ItemType, const BUFFER_SIZE: usize, const MAX_STREAMS: usize> = multi::channels::ogre_arc::full_sync::FullSync<'static, ItemType, AllocatorFullSyncArray<ItemType, BUFFER_SIZE>, BUFFER_SIZE, MAX_STREAMS>;
74pub type ChannelMultiMmapLog        <ItemType,                           const MAX_STREAMS: usize> = multi::channels::reference::mmap_log::MmapLog <'static, ItemType, MAX_STREAMS>;
75
76// Multis
77pub type MultiAtomicArc<ItemType,
78                        const BUFFER_SIZE: usize,
79                        const MAX_STREAMS: usize,
80                        const INSTRUMENTS: usize = {Instruments::LogsWithMetrics.into()}>
81    = multi::Multi<ItemType,
82                   ChannelMultiArcAtomic<ItemType, BUFFER_SIZE, MAX_STREAMS>,
83                   INSTRUMENTS,
84                   Arc<ItemType>>;
85pub type MultiCrossbeamArc<ItemType,
86                           const BUFFER_SIZE: usize,
87                           const MAX_STREAMS: usize,
88                           const INSTRUMENTS: usize = {Instruments::LogsWithMetrics.into()}>
89    = multi::Multi<ItemType,
90                   ChannelMultiArcCrossbeam<ItemType, BUFFER_SIZE, MAX_STREAMS>,
91                   INSTRUMENTS,
92                   Arc<ItemType>>;
93pub type MultiFullSyncArc<ItemType,
94                           const BUFFER_SIZE: usize,
95                           const MAX_STREAMS: usize,
96                           const INSTRUMENTS: usize = {Instruments::LogsWithMetrics.into()}>
97    = multi::Multi<ItemType,
98                   ChannelMultiArcFullSync<ItemType, BUFFER_SIZE, MAX_STREAMS>,
99                   INSTRUMENTS,
100                   Arc<ItemType>>;
101pub type MultiAtomicOgreArc<ItemType,
102                            const BUFFER_SIZE: usize,
103                            const MAX_STREAMS: usize,
104                            const INSTRUMENTS: usize = {Instruments::LogsWithMetrics.into()}>
105    = multi::Multi<ItemType,
106                   ChannelMultiOgreArcAtomic<ItemType, BUFFER_SIZE, MAX_STREAMS>,
107                   INSTRUMENTS,
108                   OgreArc<ItemType, AllocatorAtomicArray<ItemType, BUFFER_SIZE>>>;
109pub type MultiFullSyncOgreArc<ItemType,
110                              const BUFFER_SIZE: usize,
111                              const MAX_STREAMS: usize,
112                              const INSTRUMENTS: usize = {Instruments::LogsWithMetrics.into()}>
113    = multi::Multi<ItemType,
114                   ChannelMultiOgreArcFullSync<ItemType, BUFFER_SIZE, MAX_STREAMS>,
115                   INSTRUMENTS,
116                   OgreArc<ItemType, AllocatorFullSyncArray<ItemType, BUFFER_SIZE>>>;
117pub type MultiMmapLog<ItemType,
118                      const MAX_STREAMS: usize,
119                      const INSTRUMENTS: usize = {Instruments::LogsWithMetrics.into()}>
120    = multi::Multi<ItemType,
121                   ChannelMultiMmapLog<ItemType, MAX_STREAMS>,
122                   INSTRUMENTS,
123                   &'static ItemType>;