A Writer is used to write items to a Channel.
More...
#include <cpp/symbian/concurrency/common/thread/channel.h>
template<class T>
class thread::Writer< T >
A Writer is used to write items to a Channel.
You can get a pointer to a Writer by calling Channel<T>::writer(), which is the object that you should pass to code that needs to write to the channel. Writers must be closed by calling Writer::Close() when the communication is done, to notify any waiting readers that no more items will be written to the channel.
◆ Writer() [1/2]
◆ Writer() [2/2]
◆ Close() [1/2]
Marks the channel as closed, notifying any waiting readers.
See Reader::Read(). May be called at most once.
◆ Close() [2/2]
◆ OnWrite() [1/4]
Returns a Case that can be used to write the given item to the channel.
- Note
- The lifetime of the item must be guaranteed to span the call to Select() with this case. Care must be taken when passing temporaries whose lifetime may only be guaranteed for the current statement. For example:
int Select(const CaseArray &cases)
Returns the index of the first case that is ready, blocking until one is.
Definition select.h:18
A Case represents a selectable case in a Select statement.
Definition cases.h:55
- Parameters
-
| item | The item to write to the channel. If the case is selected, ownership of the item is moved to the channel. |
◆ OnWrite() [2/4]
◆ OnWrite() [3/4]
Returns a Case that can be used to write the given item to the channel.
The item is not mutated (moved from) unless the returned Case is selected.
- Note
- The
item is not mutated (moved from) unless the returned Case is selected. For example:
auto unique_ptr = absl::make_unique<T>();
writer->OnWrite(std::move(unique_ptr)) });
if (index != 2) {
unique_ptr->Foo();
}
- Parameters
-
| item | The item to write to the channel. If the case is selected, ownership of the item is moved to the channel. |
◆ OnWrite() [4/4]
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ Write() [1/4]
Writes the given item to the channel, blocking until it can be written.
If the channel is closed, this will throw an exception.
- Note
- The item is copied into the channel, so it must be copy-constructible.
◆ Write() [2/4]
◆ Write() [3/4]
Writes the given item to the channel, blocking until it can be written.
If the channel is closed, this will throw an exception.
- Note
- The item is moved into the channel, so it must be move-constructible.
◆ Write() [4/4]
◆ WriteUnlessCancelled() [1/4]
Returns false iff the calling fiber is cancelled before the value can be written.
- Parameters
-
| item | The item to write to the channel. |
- Returns
- True if the item was written to the channel, false if the calling fiber was cancelled before the item could be written.
◆ WriteUnlessCancelled() [2/4]
◆ WriteUnlessCancelled() [3/4]
Returns false iff the calling fiber is cancelled before the value can be written.
- Note
- The item is only moved into the channel if the function returns true.
- Parameters
-
| item | The item to write to the channel. If the function returns true, the ownership of the item is moved to the channel. |
- Returns
- True if the item was written to the channel, false if the calling fiber was cancelled before the item could be written.
◆ WriteUnlessCancelled() [4/4]
◆ Channel< T >
The documentation for this class was generated from the following files:
- cpp/symbian/concurrency/common/thread/channel.h
- cpp/symbian/concurrency/guest/thread/channel.h