pub struct LlmpSender<SP> where
SP: ShMemProvider, {
pub id: ClientId,
pub last_msg_sent: *const LlmpMsg,
pub out_shmems: Vec<LlmpSharedMap<SP::ShMem>>,
pub keep_pages_forever: bool,
/* private fields */
}
Expand description
Sending end on a (unidirectional) sharedmap channel
Fields
id: ClientId
ID of this sender.
last_msg_sent: *const LlmpMsg
Ref to the last message this sender sent on the last page. If null, a new page (just) started.
out_shmems: Vec<LlmpSharedMap<SP::ShMem>>
A vec of page wrappers, each containing an initialized ShMem
keep_pages_forever: bool
If true, pages will never be pruned. The broker uses this feature. By keeping the message history around, new clients may join at any time in the future.
Implementations
sourceimpl<SP> LlmpSender<SP> where
SP: ShMemProvider,
impl<SP> LlmpSender<SP> where
SP: ShMemProvider,
An actor on the sending part of the shared map
sourcepub fn new(
shmem_provider: SP,
id: ClientId,
keep_pages_forever: bool
) -> Result<Self, Error>
pub fn new(
shmem_provider: SP,
id: ClientId,
keep_pages_forever: bool
) -> Result<Self, Error>
Create a new LlmpSender
using a given ShMemProvider
, and id
.
If keep_pages_forever
is true
, ShMem
will never be freed.
If it is false
, the pages will be unmapped once they are full, and have been mapped by at least one LlmpReceiver
.
sourcepub unsafe fn reset(&mut self)
pub unsafe fn reset(&mut self)
Completely reset the current sender map. Afterwards, no receiver should read from it at a different location. This is only useful if all connected llmp parties start over, for example after a crash.
Safety
Only safe if you really really restart the page on everything connected No receiver should read from this page at a different location.
sourcepub fn on_existing_from_env(
shmem_provider: SP,
env_name: &str
) -> Result<Self, Error>
pub fn on_existing_from_env(
shmem_provider: SP,
env_name: &str
) -> Result<Self, Error>
Reattach to a vacant out_shmem
, to with a previous sender stored the information in an env before.
sourcepub fn to_env(&self, env_name: &str) -> Result<(), Error>
pub fn to_env(&self, env_name: &str) -> Result<(), Error>
Store the info to this sender to env.
A new client can reattach to it using LlmpSender::on_existing_from_env()
.
sourcepub fn await_safe_to_unmap_blocking(&self)
pub fn await_safe_to_unmap_blocking(&self)
Waits for this sender to be save to unmap. If a receiver is involved, this function should always be called.
sourcepub fn safe_to_unmap(&self) -> bool
pub fn safe_to_unmap(&self) -> bool
If we are allowed to unmap this client
sourcepub unsafe fn mark_safe_to_unmap(&mut self)
pub unsafe fn mark_safe_to_unmap(&mut self)
For debug purposes: Mark save to unmap, even though it might not have been read by a receiver yet.
Safety
If this method is called, the page may be unmapped before it is read by any receiver.
sourcepub fn on_existing_shmem(
shmem_provider: SP,
current_out_shmem: SP::ShMem,
last_msg_sent_offset: Option<u64>
) -> Result<Self, Error>
pub fn on_existing_shmem(
shmem_provider: SP,
current_out_shmem: SP::ShMem,
last_msg_sent_offset: Option<u64>
) -> Result<Self, Error>
Reattach to a vacant out_shmem
.
It is essential, that the receiver (or someone else) keeps a pointer to this map
else reattach will get a new, empty page, from the OS, or fail.
sourcepub fn alloc_next(&mut self, buf_len: usize) -> Result<*mut LlmpMsg, Error>
pub fn alloc_next(&mut self, buf_len: usize) -> Result<*mut LlmpMsg, Error>
Allocates the next space on this sender page
sourcepub unsafe fn cancel_send(&mut self, msg: *mut LlmpMsg)
pub unsafe fn cancel_send(&mut self, msg: *mut LlmpMsg)
Cancel send of the next message, this allows us to allocate a new message without sending this one.
Safety
They msg pointer may no longer be used after cancel_send
sourcepub unsafe fn shrink_alloced(
&mut self,
msg: *mut LlmpMsg,
shrinked_len: usize
) -> Result<(), Error>
pub unsafe fn shrink_alloced(
&mut self,
msg: *mut LlmpMsg,
shrinked_len: usize
) -> Result<(), Error>
sourcepub fn send_buf(&mut self, tag: Tag, buf: &[u8]) -> Result<(), Error>
pub fn send_buf(&mut self, tag: Tag, buf: &[u8]) -> Result<(), Error>
Allocates a message of the given size, tags it, and sends it off.
sourcepub fn send_buf_with_flags(
&mut self,
tag: Tag,
flags: Flags,
buf: &[u8]
) -> Result<(), Error>
pub fn send_buf_with_flags(
&mut self,
tag: Tag,
flags: Flags,
buf: &[u8]
) -> Result<(), Error>
Send a buf
with the given flags
.
sourcepub fn describe(&self) -> Result<LlmpDescription, Error>
pub fn describe(&self) -> Result<LlmpDescription, Error>
Describe this LlmpClient
in a way that it can be restored later, using Self::on_existing_from_description
.
sourcepub fn on_existing_from_description(
shmem_provider: SP,
description: &LlmpDescription
) -> Result<Self, Error>
pub fn on_existing_from_description(
shmem_provider: SP,
description: &LlmpDescription
) -> Result<Self, Error>
Create this client on an existing map from the given description.
Acquired with [self.describe
].
Trait Implementations
Auto Trait Implementations
impl<SP> RefUnwindSafe for LlmpSender<SP> where
SP: RefUnwindSafe,
<SP as ShMemProvider>::ShMem: RefUnwindSafe,
impl<SP> !Send for LlmpSender<SP>
impl<SP> !Sync for LlmpSender<SP>
impl<SP> Unpin for LlmpSender<SP> where
SP: Unpin,
<SP as ShMemProvider>::ShMem: Unpin,
impl<SP> UnwindSafe for LlmpSender<SP> where
SP: UnwindSafe,
<SP as ShMemProvider>::ShMem: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Tail, T> Prepend<T> for Tail
impl<Tail, T> Prepend<T> for Tail
type PreprendResult = Tail
type PreprendResult = Tail
The Resulting TupleList
, of an Prepend::prepend()
call,
including the prepended entry. Read more
sourcefn prepend(self, value: T) -> (T, <Tail as Prepend<T>>::PreprendResult)
fn prepend(self, value: T) -> (T, <Tail as Prepend<T>>::PreprendResult)
Prepend a value to this tuple, returning a new tuple with prepended value.