Turi Create  4.0
turi::neural_net::FuturesSubscriber< T > Class Template Reference

#include <ml/neural_net/combine_futures_subscriber.hpp>

Public Member Functions

std::future< std::unique_ptr< T > > Request ()
 
void Receive (std::shared_ptr< Subscription > subscription) override
 
Demand Receive (Input element) override
 
void Receive (Completion completion) override
 

Detailed Description

template<typename T>
class turi::neural_net::FuturesSubscriber< T >

Subscriber that synchronously produces futures for promises to be fulfilled by its publisher.

This type is useful for integrating Publishers into existing code bases that rely on synchronous behavior or futures.

Client code MUST call FuturesSubscriber::Cancel() to tear down a FuturesSubscriber instance. This requirement can be handled automatically using the FuturesStream wrapper class below.

Definition at line 36 of file combine_base.hpp.

Member Function Documentation

◆ Receive() [1/3]

template<typename T >
void turi::neural_net::FuturesSubscriber< T >::Receive ( std::shared_ptr< Subscription subscription)
inlineoverridevirtual

The first signal that a Subscriber receives from a Publisher, passing the Subscription that the Subscriber can use to control the flow of values.

A Subscriber may only have one Publisher. If it somehow receives more than one Subscription, it should call Subscription::Cancel() on any instances received after the first.

A Subscriber is explictly allowed to demand values synchronously from within its implementation of this method.

Implements turi::neural_net::Subscriber< T >.

Definition at line 85 of file combine_futures_subscriber.hpp.

◆ Receive() [2/3]

template<typename T >
Demand turi::neural_net::FuturesSubscriber< T >::Receive ( Input  element)
inlineoverridevirtual

Transmits a value from the Publisher to this Subscriber.

A Subcriber should never receive more calls to this method than the total Demand it has requested from its publisher. Subscribers should only demand more elements from within this method via its return value.

Implements turi::neural_net::Subscriber< T >.

Definition at line 106 of file combine_futures_subscriber.hpp.

◆ Receive() [3/3]

template<typename T >
void turi::neural_net::FuturesSubscriber< T >::Receive ( Completion  completion)
inlineoverridevirtual

Signals completion of the stream of values from the Publisher.

A Subscriber should not receive any further signals of any kind after receiving a Completion.

Implements turi::neural_net::Subscriber< T >.

Definition at line 117 of file combine_futures_subscriber.hpp.

◆ Request()

template<typename T >
std::future<std::unique_ptr<T> > turi::neural_net::FuturesSubscriber< T >::Request ( )
inline

Submits a request for a value to the Publisher but immediately returns a future for that value.

If the publisher returned a failure for this request or any previous request from this subscriber, then the future will store that exception. If the publisher returned Completion::IsFinished() for this request or any previous request, or if Cancel is called, then the future will store null.

Definition at line 48 of file combine_futures_subscriber.hpp.


The documentation for this class was generated from the following files: