Skip to main content

EventQueue

Struct EventQueue 

Source
pub struct EventQueue<E: SubscriptionItem = Event> { /* private fields */ }
Expand description

A queue of the events of one subscription (EventQueue.create(DXFeedSubscription)): a poll returns them as E, in their order.

The queue closes when the subscription closes, when close is called and when it is dropped. The subscription keeps the executor of the queue for its life, also after the queue is closed. The queue can be shared by threads, but poll it from one thread at a time.

Implementations§

Source§

impl<E: SubscriptionItem> EventQueue<E>

Source

pub fn new(subscription: &DXFeedSubscription<E>) -> Result<Self>

Creates a queue of the events of subscription.

Create it before the symbols are added to a subscription attached to a feed. A subscription with an executor or a queue, or one attached to a feed that has symbols, is Error::Java of java.lang.IllegalStateException; on a subscription that has symbols, add its event listeners first.

Source

pub fn wake_up(&self) -> Result<()>

Makes the poll in progress, or the next one, return PollResult::NoEvents at once unless it has events; several wake-ups before a poll wake up one poll.

Source

pub fn close(&self) -> Result<()>

Closes the queue: the poll in progress returns the events it has or PollResult::Closed, and the events that no poll returned are dropped and counted. It does not wait for the poll in progress; closing a closed queue does nothing.

Source

pub fn get_dropped_events(&self) -> Result<i64>

The number of the events of the subscription that were lost, which never decreases: if it grew since the previous poll, events were lost before those that the last poll returned.

Source

pub unsafe fn set_ready_signal(&self, signal: ReadySignal) -> Result<()>

Sets, replaces or removes the ready signal of the queue (dxfg_v4_EventQueue_setReadySignal); see ReadySignal. Needs the cargo feature experimental.

§Safety

The object of the signal must stay open, and be the same object, until another signal replaces it, ReadySignal::None removes it, close returns on any thread or a poll returns PollResult::Closed: the SDK writes to it until then. Dropping the queue or closing its subscription does not count; to stop an event loop, close the queue, and close the object after a poll returns Closed.

Source§

impl<E: SubscriptionItem + TryFrom<Event>> EventQueue<E>

Source

pub fn poll( &self, timeout: Option<Duration>, limit: usize, ) -> Result<PollResult<Vec<E>>>

Waits for the events of the subscription and returns them; the event listeners of the subscription run in the poll, on this thread.

timeout is how long to wait: zero returns at once, None waits until events arrive, the queue is woken up or closed. After the first events the poll only completes the retrieval in progress. limit stops the retrieval after that many events, 0 for no limit; a batch may exceed it. A failure of the SDK drops the events that the poll took, counted in get_dropped_events, and the next poll goes on with the next ones; an event that the crate cannot copy fails the poll and drops its batch without counting it.

Inside a listener or a callback of the crate it returns Error::InCallback.

Trait Implementations§

Source§

impl<E: SubscriptionItem> Debug for EventQueue<E>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<E> Forget for EventQueue<E>

§

impl<E> Freeze for EventQueue<E>
where PhantomData<fn() -> E>: Freeze,

§

impl<E> Move for EventQueue<E>

§

impl<E> RefUnwindSafe for EventQueue<E>
where PhantomData<fn() -> E>: RefUnwindSafe,

§

impl<E> Send for EventQueue<E>
where PhantomData<fn() -> E>: Send,

§

impl<E> Sync for EventQueue<E>
where PhantomData<fn() -> E>: Sync,

§

impl<E> Unpin for EventQueue<E>
where PhantomData<fn() -> E>: Unpin,

§

impl<E> UnsafeUnpin for EventQueue<E>
where PhantomData<fn() -> E>: UnsafeUnpin,

§

impl<E> UnwindSafe for EventQueue<E>
where PhantomData<fn() -> E>: UnwindSafe,

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, 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.