Symbian platform (C++)
SDK native APIs, runtime and tooling
Loading...
Searching...
No Matches
thread::Reader< T > Class Template Reference

A Reader is used to read items from a Channel. More...

#include <cpp/symbian/concurrency/common/thread/channel.h>

Public Member Functions

 Reader (const Reader &)=delete
 
Reader & operator= (const Reader &)=delete
 
bool Read (T *absl_nonnull item)
 Reads an item from the channel, blocking until it can be read.
 
Case OnRead (T *absl_nonnull item, bool *absl_nonnull ok)
 Returns a Case that can be used to wait for and synchronise on reading an item from the channel.
 
 Reader (const Reader &)=delete
 
Reader & operator= (const Reader &)=delete
 
bool Read (T *out)
 
Case OnRead (T *out, bool *ok)
 

Friends

class Channel< T >
 

Detailed Description

template<class T>
class thread::Reader< T >

A Reader is used to read items from a Channel.

You can get a pointer to a Reader by calling Channel<T>::reader(), which is the object that you should pass to code that needs to read from the channel.

Constructor & Destructor Documentation

◆ Reader() [1/2]

template<class T >
thread::Reader< T >::Reader ( const Reader< T > &  )
delete

◆ Reader() [2/2]

template<class T >
thread::Reader< T >::Reader ( const Reader< T > &  )
delete

Member Function Documentation

◆ OnRead() [1/2]

template<typename T >
Case thread::Reader< T >::OnRead ( T *absl_nonnull  item,
bool *absl_nonnull  ok 
)

Returns a Case that can be used to wait for and synchronise on reading an item from the channel.

Note
The item is only read out of the channel if the returned Case is selected. For example:
// `reader` is a thread::Reader<T> pointer from a channel
// with non-empty strings
std::string item;
bool ok;
const int selected = thread::Select({
reader->OnRead(&item, &ok),
});
if (selected == 0) {
assert(!ok);
assert(item.empty());
}
Case OnCancel()
Definition fiber.cc:294
int Select(const CaseArray &cases)
Returns the index of the first case that is ready, blocking until one is.
Definition select.h:18
Returns
True if an item was read from the channel, false if the channel was closed before or while reading.

◆ OnRead() [2/2]

template<class T >
Case thread::Reader< T >::OnRead ( T *  out,
bool *  ok 
)
inline

◆ operator=() [1/2]

template<class T >
Reader & thread::Reader< T >::operator= ( const Reader< T > &  )
delete

◆ operator=() [2/2]

template<class T >
Reader & thread::Reader< T >::operator= ( const Reader< T > &  )
delete

◆ Read() [1/2]

template<typename T >
bool thread::Reader< T >::Read ( T *absl_nonnull  item)

Reads an item from the channel, blocking until it can be read.

Returns false if and only if the channel is closed.

On returning true, the item is moved into the provided pointer.

Returns
True if an item was read from the channel, false if the channel was closed before or while reading.

◆ Read() [2/2]

template<class T >
bool thread::Reader< T >::Read ( T *  out)
inline

Friends And Related Symbol Documentation

◆ Channel< T >

template<class T >
friend class Channel< T >
friend

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