|
| | BasicWriter (char const *topic_name, size_t capacity, std::optional< numapp::MemPolicy > const &mempolicy=std::nullopt) |
| | Creates a writer and allocates shared memory to have room for capacity Ts.
|
| |
| char const * | TopicName () const noexcept |
| | Get queue topic name.
|
| |
| constexpr size_t | Capacity () const noexcept |
| | Query queue capacity, which is the number of elements the queue can hold.
|
| |
| constexpr size_t | Size () noexcept |
| | Query number of elements in the queue.
|
| |
| constexpr bool | IsClosed () const noexcept |
| | Query whether queue is closed or not.
|
| |
| constexpr void | Close () noexcept |
| | Close queue for further writing.
|
| |
| std::error_code | Write (T const &data, Notify notify_readers) noexcept |
| | Append single element to queue, possibly overwriting the front element.
|
| |
| constexpr void | Pop () noexcept |
| | Remove single element from queue.
|
| |
| std::error_code | Write (const T *data, size_t count, Notify notify_readers) noexcept |
| | Write count elements to queue.
|
| |
template<class T, class ConditionPolicy, class ShmTraits = detail::BoostInterprocessTraits>
class ipcq::BasicWriter< T, ConditionPolicy, ShmTraits >
Queue writer class.
- Template Parameters
-
Basic Usage:
struct MyTopicType {
...
};
// Create writer for the topic "topicname" with type MyTopicType.
auto writer = ipcq::Writer<MyTopicType>("topicname", 100);
while (!shouldStop) {
MyTopicType sample;
// Prepare sample
...
auto err = writer.Write(sample, ipcq::Notify::NotifyAll);
if (err) {
// Handle error
break;
}
}
// Signal to readers that the queue is now closed.
writer.Close();
- See also
- ipcq::BoostConditionPolicy ipcq::SpinConditionPolicy.
Definition at line 69 of file writer.hpp.
template<class T, class ConditionPolicy, class ShmTraits = detail::BoostInterprocessTraits>
Close queue for further writing.
Any waiting readers will be notified. Once existing data is read out subsequent reads will fail with ipcq::Error::Closed.
- Postcondition
- Shared memory remains valid but new reader instances will not attach.
- Synchronization
- Synchronizes with SHM using release semantics.
- See also
- IsClosed()
Definition at line 149 of file writer.hpp.