[−][src]Struct serenity::client::bridge::gateway::ShardQueuer
The shard queuer is a simple loop that runs indefinitely to manage the startup of shards.
A shard queuer instance should be run in its own thread, due to the blocking nature of the loop itself as well as a 5 second thread sleep between shard starts.
Fields
data: Arc<Mutex<ShareMap>>
A copy of Client::data
to be given to runners for contextual
dispatching.
event_handler: Arc<H>
A reference to an EventHandler
, such as the one given to the
Client
.
framework: Arc<Mutex<Option<Box<dyn Framework + Send>>>>
A copy of the framework
last_start: Option<Instant>
The instant that a shard was last started.
This is used to determine how long to wait between shard IDENTIFYs.
manager_tx: Sender<ShardManagerMessage>
A copy of the sender channel to communicate with the
ShardManagerMonitor
.
queue: VecDeque<(u64, u64)>
The shards that are queued for booting.
This will typically be filled with previously failed boots.
runners: Arc<Mutex<HashMap<ShardId, ShardRunnerInfo>>>
A copy of the map of shard runners.
rx: Receiver<ShardQueuerMessage>
A receiver channel for the shard queuer to be told to start shards.
threadpool: ThreadPool
A copy of a threadpool to give shard runners.
For example, when using the Client
, this will be a copy of
Client::threadpool
.
token: Arc<Mutex<String>>
A copy of the token to connect with.
voice_manager: Arc<Mutex<ClientVoiceManager>>
A copy of the client's voice manager.
ws_url: Arc<Mutex<String>>
A copy of the URI to use to connect to the gateway.
Methods
impl<H: EventHandler + Send + Sync + 'static> ShardQueuer<H>
[src]
impl<H: EventHandler + Send + Sync + 'static> ShardQueuer<H>
pub fn run(&mut self)
[src]
pub fn run(&mut self)
Begins the shard queuer loop.
This will loop over the internal rx
for ShardQueuerMessage
s,
blocking for messages on what to do.
If a ShardQueuerMessage::Start
is received, this will:
- Check how much time has passed since the last shard was started
- If the amount of time is less than the ratelimit, it will sleep until that time has passed
- Start the shard by ID
If a ShardQueuerMessage::Shutdown
is received, this will return and
the loop will be over.
Note: This should be run in its own thread due to the blocking nature of the loop.
Auto Trait Implementations
impl<H> Send for ShardQueuer<H>
impl<H> Send for ShardQueuer<H>
impl<H> !Sync for ShardQueuer<H>
impl<H> !Sync for ShardQueuer<H>
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more
impl<T> Erased for T
impl<T> Erased for T
impl<T> Typeable for T where
T: Any,
impl<T> Typeable for T where
T: Any,
impl<T> UnsafeAny for T where
T: Any,
impl<T> UnsafeAny for T where
T: Any,