Struct veloren_network::participant::BParticipant
source · pub struct BParticipant {
local_pid: Pid,
remote_pid: Pid,
remote_pid_string: String,
offset_sid: Sid,
channels: Arc<RwLock<HashMap<Cid, Mutex<ChannelInfo>>>>,
streams: RwLock<HashMap<Sid, StreamInfo>>,
run_channels: Option<ControlChannels>,
shutdown_barrier: AtomicI32,
metrics: Arc<NetworkMetrics>,
open_stream_channels: Arc<Mutex<Option<OpenStreamInfo>>>,
}
Fields§
§local_pid: Pid
§remote_pid: Pid
§remote_pid_string: String
§offset_sid: Sid
§channels: Arc<RwLock<HashMap<Cid, Mutex<ChannelInfo>>>>
§streams: RwLock<HashMap<Sid, StreamInfo>>
§run_channels: Option<ControlChannels>
§shutdown_barrier: AtomicI32
§metrics: Arc<NetworkMetrics>
§open_stream_channels: Arc<Mutex<Option<OpenStreamInfo>>>
Implementations§
source§impl BParticipant
impl BParticipant
const BARR_CHANNEL: i32 = 1i32
const BARR_RECV: i32 = 4i32
const BARR_SEND: i32 = 2i32
const TICK_TIME: Duration = _
const TICK_TIME_MS: u64 = 5u64
pub(crate) fn new( local_pid: Pid, remote_pid: Pid, offset_sid: Sid, metrics: Arc<NetworkMetrics>, ) -> (Self, UnboundedSender<(Prio, Promises, Bandwidth, Sender<Stream>)>, UnboundedReceiver<Stream>, UnboundedReceiver<ParticipantEvent>, UnboundedSender<(Cid, Sid, Protocols, ConnectAddr, Sender<()>)>, Sender<(Duration, Sender<Result<(), ParticipantError>>)>, Receiver<f32>)
pub async fn run(self, b2s_prio_statistic_s: UnboundedSender<(Pid, u64, u64)>)
fn best_protocol( all: &SortedVec<Cid, SendProtocols>, promises: Promises, ) -> Option<Cid>
async fn send_mgr( &self, a2b_open_stream_r: UnboundedReceiver<(Prio, Promises, Bandwidth, Sender<Stream>)>, a2b_close_stream_r: UnboundedReceiver<Sid>, a2b_msg_r: Receiver<(Sid, Bytes)>, b2b_add_protocol_r: UnboundedReceiver<(Cid, SendProtocols)>, b2b_close_send_protocol_r: Receiver<Cid>, b2b_notify_send_of_recv_open_r: Receiver<(Cid, Sid, Prio, Promises, Bandwidth)>, b2b_notify_send_of_recv_close_r: Receiver<(Cid, Sid)>, b2a_event_s: UnboundedSender<ParticipantEvent>, _b2s_prio_statistic_s: UnboundedSender<(Pid, u64, u64)>, b2a_bandwidth_stats_s: Sender<f32>, )
async fn recv_mgr( &self, b2a_stream_opened_s: UnboundedSender<Stream>, b2b_add_protocol_r: UnboundedReceiver<(Cid, RecvProtocols)>, b2b_force_close_recv_protocol_r: Receiver<Cid>, b2b_close_send_protocol_s: Sender<Cid>, b2b_notify_send_of_recv_open_r: Sender<(Cid, Sid, Prio, Promises, Bandwidth)>, b2b_notify_send_of_recv_close_s: Sender<(Cid, Sid)>, )
async fn create_channel_mgr( &self, s2b_create_channel_r: UnboundedReceiver<(Cid, Sid, Protocols, ConnectAddr, Sender<()>)>, b2b_add_send_protocol_s: UnboundedSender<(Cid, SendProtocols)>, b2b_add_recv_protocol_s: UnboundedSender<(Cid, RecvProtocols)>, b2a_event_s: UnboundedSender<ParticipantEvent>, )
sourceasync fn participant_shutdown_mgr(
&self,
s2b_shutdown_bparticipant_r: Receiver<(Duration, Sender<Result<(), ParticipantError>>)>,
b2b_close_send_protocol_s: Sender<Cid>,
b2b_force_close_recv_protocol_s: Sender<Cid>,
)
async fn participant_shutdown_mgr( &self, s2b_shutdown_bparticipant_r: Receiver<(Duration, Sender<Result<(), ParticipantError>>)>, b2b_close_send_protocol_s: Sender<Cid>, b2b_force_close_recv_protocol_s: Sender<Cid>, )
sink shutdown: Situation AS, AR, BS, BR. A wants to close. AS shutdown. BR notices shutdown and tries to stops BS. (success) BS shutdown AR notices shutdown and tries to stop AS. (fails) For the case where BS didn’t get shutdowned, e.g. by a handing situation on the remote, we have a timeout to also force close AR.
This fn will:
- stop api to interact with bparticipant by closing sendmsg and openstream
- stop the send_mgr (it will take care of clearing the queue and finish with a Shutdown)
- force stop recv after 60 seconds
- this fn finishes last and afterwards BParticipant drops
before calling this fn, make sure s2b_create_channel
is closed!
If BParticipant kills itself managers stay active till this function is
called by api to get the result status
sourceasync fn delete_stream(&self, sid: Sid)
async fn delete_stream(&self, sid: Sid)
Stopping API and participant usage Protocol will take care of the order of the frame
async fn create_stream( &self, sid: Sid, prio: Prio, promises: Promises, guaranteed_bandwidth: Bandwidth, ) -> Stream
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for BParticipant
impl !RefUnwindSafe for BParticipant
impl Send for BParticipant
impl Sync for BParticipant
impl Unpin for BParticipant
impl !UnwindSafe for BParticipant
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more