Skip to main content

OwnerTable

Struct OwnerTable 

Source
pub struct OwnerTable {
    map: BTreeMap<String, Entry>,
}
Expand description

URL → 持ち主の組と段階。

Fields§

§map: BTreeMap<String, Entry>

Implementations§

Source§

impl OwnerTable

Source

pub const fn new() -> Self

Source

pub fn len(&self) -> usize

表にある URL の数。

Source

pub fn is_empty(&self) -> bool

Source

pub fn request(&mut self, key: &str, g: u8) -> bool

組 g が key を求めた。初めての URL なら真(呼び出し側が待ち行列へ積む)、 既に表にあれば持ち主に g を足して偽(重複を省く)。

Source

pub fn state(&self, key: &str) -> Option<State>

段階(表に無ければ None)。

Source

pub fn is_live(&self, key: &str) -> bool

まだ持ち主が居るか(表に無ければ偽)。

Source

pub fn start(&mut self, key: &str)

ワーカーが取り出した(取得を始める)。

Source

pub fn finish(&mut self, key: &str) -> bool

取得を終えた。持ち主がまだ居れば Done にして真(結果を使う)。 持ち主が居なければ表から外して偽(結果を捨てる。開き直したときにまた積めるように)。

Source

pub fn requeue(&mut self, key: &str) -> bool

取れなかったので待ち行列へ戻す。持ち主がまだ居れば Pending にして真、居なければ表から外して偽(戻さない)。

Source

pub fn sole_owner<'a>(&self, keys: impl IntoIterator<Item = &'a str>) -> u8

keys をまとめて取るときに借りる組: 持ち主がただ 1 つの組(0 以外)なら、その番号。 持ち主が複数・組 0 を含む・表に無いなら 0(借りない。止めたアプリの合図で取得を打ち切らない)。

Source

pub fn close_group(&mut self, g: u8) -> Closed

組 g が閉じた(そのアプリが止められた)。持ち主から g を外し、持ち主が居なくなった URL を片付ける。

Trait Implementations§

Source§

impl Default for OwnerTable

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.