[][src]Struct serenity::client::bridge::gateway::ShardQueuer

pub struct ShardQueuer<H: EventHandler + Send + Sync + 'static, RH: RawEventHandler + Send + Sync + 'static> {
    pub data: Arc<RwLock<ShareMap>>,
    pub event_handler: Option<Arc<H>>,
    pub raw_event_handler: Option<Arc<RH>>,
    pub framework: Arc<Mutex<Option<Box<dyn Framework + Send>>>>,
    pub last_start: Option<Instant>,
    pub manager_tx: Sender<ShardManagerMessage>,
    pub queue: VecDeque<(u64, u64)>,
    pub runners: Arc<Mutex<HashMap<ShardId, ShardRunnerInfo>>>,
    pub rx: Receiver<ShardQueuerMessage>,
    pub threadpool: ThreadPool,
    pub voice_manager: Arc<Mutex<ClientVoiceManager>>,
    pub ws_url: Arc<Mutex<String>>,
    pub cache_and_http: Arc<CacheAndHttp>,
}

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<RwLock<ShareMap>>

A copy of Client::data to be given to runners for contextual dispatching.

event_handler: Option<Arc<H>>

A reference to an EventHandler, such as the one given to the Client.

raw_event_handler: Option<Arc<RH>>

A reference to an RawEventHandler, 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.

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.

cache_and_http: Arc<CacheAndHttp>

Methods

impl<H: EventHandler + Send + Sync + 'static, RH: RawEventHandler + Send + Sync + 'static> ShardQueuer<H, RH>[src]

pub fn run(&mut self)[src]

Begins the shard queuer loop.

This will loop over the internal rx for ShardQueuerMessages, blocking for messages on what to do.

If a ShardQueuerMessage::Start is received, this will:

  1. Check how much time has passed since the last shard was started
  2. If the amount of time is less than the ratelimit, it will sleep until that time has passed
  3. 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, RH> !Sync for ShardQueuer<H, RH>

impl<H, RH> Send for ShardQueuer<H, RH>

impl<H, RH> Unpin for ShardQueuer<H, RH>

impl<H, RH> !RefUnwindSafe for ShardQueuer<H, RH>

impl<H, RH> !UnwindSafe for ShardQueuer<H, RH>

Blanket Implementations

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Erased for T

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Err = <U as TryFrom<T>>::Err

impl<T> UnsafeAny for T where
    T: Any