Main Page Class List Class Members

# Nv::Blast::TkEventQueue Class Reference

`#include <NvBlastTkEventQueue.h>`

List of all members.

## Public Member Functions
template<class T >
void | addEvent (T *payload)
void | addListener (TkEventListener &l)
template<typename T >
T * | allocData ()
void | dispatch (const Array< TkEvent >::type &events) const
void | dispatch ()
| operator const Array< TkEvent >::type & ()
void | protect (bool enable)
void | removeListener (TkEventListener &l)
void | reserveData (size_t size)
void | reserveEvents (uint32_t n)
void | reset ()
| TkEventQueue ()

## Detailed Description

A dispatcher queue providing preallocation and thread-safe insertions therein.

Typical usage:

- preallocate space for events and payload:
  - reserveEvents, reserveData
- enable asserts to detect undersized storage (allocations are not thread safe):
  - protect(true)
- get pointers to payload data and events to fill in, thread safe for preallocated memory:
  - allocData, addEvent
- back on main thread, ensure consistency:
  - protect(false)

- continue adding events and payload on main thread if necessary like above (allocations are safe here) eventually dispatch, or reset if dispatched by proxy

## Constructor & Destructor Documentation

Nv::Blast::TkEventQueue::TkEventQueue | ( |  | ) | `[inline]`

## Member Function Documentation

template<class T >

void Nv::Blast::TkEventQueue::addEvent | ( | T * | payload | ) | `[inline]`

Queue an event with a payload.

void Nv::Blast::TkEventQueue::addListener | ( | TkEventListener & | l | ) | `[inline]`

Add a listener to dispatch to.

template<typename T >

T* Nv::Blast::TkEventQueue::allocData | ( |  | ) | `[inline]`

Request storage for payload.

void Nv::Blast::TkEventQueue::dispatch | ( | const Array< TkEvent >::type & | events | ) | const`[inline]`

Proxy function to dispatch events to this queue's listeners.

void Nv::Blast::TkEventQueue::dispatch | ( |  | ) | `[inline]`

Dispatch the stored events to the registered listeners. After dispatch, all data is invalidated.

Nv::Blast::TkEventQueue::operator const Array< TkEvent >::type & | ( |  | ) | `[inline]`

Peek events queue for dispatch. Do not use in protected state.

void Nv::Blast::TkEventQueue::protect | ( | bool | enable | ) | `[inline]`

Debug help to catch (unwanted) allocations during task work. Note that this will not actually avoid allocations, but assert in debug builds.

Set true before using in distributed environment. Set false to return to single-thread mode.

void Nv::Blast::TkEventQueue::removeListener | ( | TkEventListener & | l | ) | `[inline]`

Remove a listener from dispatch list.

void Nv::Blast::TkEventQueue::reserveData | ( | size_t | size | ) | `[inline]`

Preallocate a memory block of size Bytes for payload data. Note that this will inevitably allocate a new memory block. Subsequent calls to allocData will use this memory piecewise.

void Nv::Blast::TkEventQueue::reserveEvents | ( | uint32_t | n | ) | `[inline]`

Preallocate space for events.

void Nv::Blast::TkEventQueue::reset | ( |  | ) | `[inline]`

Restores initial state. Data memory is currently not being reused. To be improved.

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

- sdk/toolkit/source/NvBlastTkEventQueue.h