1use vasi::VirtualAddressSpaceIndependent;
2use vasi_sync::scchannel::SelfContainedChannel;
34use crate::shim_event::{ShimEventToShadow, ShimEventToShim};
56/// Manages communication between the Shadow process and the shim library
7/// running inside Shadow managed threads.
8#[derive(VirtualAddressSpaceIndependent)]
9#[repr(C)]
10// In the microbenchmarks introduced in
11// https://github.com/shadow/shadow/pull/2791, adding a large alignment to
12// the mock IPC helped make some measurement artifacts go away by ensuring
13// the two channels are on the same cache line.
14pub struct IPCData {
15 shadow_to_plugin: SelfContainedChannel<ShimEventToShim>,
16 plugin_to_shadow: SelfContainedChannel<ShimEventToShadow>,
17}
1819impl IPCData {
20pub fn new() -> Self {
21Self {
22 shadow_to_plugin: SelfContainedChannel::new(),
23 plugin_to_shadow: SelfContainedChannel::new(),
24 }
25 }
2627/// Returns a reference to the "Shadow to Plugin" channel.
28pub fn to_plugin(&self) -> &SelfContainedChannel<ShimEventToShim> {
29&self.shadow_to_plugin
30 }
3132/// Returns a reference to the "Plugin to Shadow" channel.
33pub fn to_shadow(&self) -> &SelfContainedChannel<ShimEventToShadow> {
34&self.plugin_to_shadow
35 }
3637/// Returns a reference to the "Plugin to Shadow" channel.
38pub fn from_plugin(&self) -> &SelfContainedChannel<ShimEventToShadow> {
39&self.plugin_to_shadow
40 }
4142/// Returns a reference to the "Shadow to Plugin" channel.
43pub fn from_shadow(&self) -> &SelfContainedChannel<ShimEventToShim> {
44&self.shadow_to_plugin
45 }
46}
4748impl Default for IPCData {
49fn default() -> Self {
50Self::new()
51 }
52}