bm::queue_sync< Value, Lock > Class Template Reference
BitMagic Library » Task parallel programming

Thread-sync queue with MT access protecion. More...

`#include <bmthreadpool.h>`

Inheritance diagram for bm::queue_sync< Value, Lock >:
[legend]

## Public Types

typedef Value | value_type
typedef Lock | lock_type

## Public Member Functions

| queue_sync () noexcept
| constructor
void | push (const value_type &v)
| Push value to the back of the queue.
void | push_no_lock (const value_type &v)
| Push value to the back of the queue without lock protection It is assumed that processing did not start and we are just staging the batch.
bool | try_pop (value_type &v)
| Extract value.
bool | empty () const
void | lock () noexcept(bm::is_lock_noexcept< lock_type >::value)
| lock the queue access
bool | try_lock () noexcept(bm::is_lock_noexcept< lock_type >::value)
| Try to lock the queue exclusively.
void | unlock () noexcept(bm::is_lock_noexcept< lock_type >::value)
| unlock the queue access

## Protected Types

typedef std::queue< value_type > | queue_type

## Protected Attributes

std::mutex | signal_mut_
| signal mutex for q submissions
std::condition_variable | queue_push_cond_
| mutex paired conditional

## Friends

template<typename QV, typename L>
class | bm::thread_pool

## Detailed Description

template<typename Value, typename Lock>
class bm::queue_sync< Value, Lock >

Thread-sync queue with MT access protecion.

Definition at line 129 of file bmthreadpool.h.

## Member Typedef Documentation

## lock_type

template<typename Value, typename Lock>

typedef Lock bm::queue_sync< Value, Lock >::lock_type

Definition at line 133 of file bmthreadpool.h.

## queue_type

template<typename Value, typename Lock>

typedef std::queue<value_type> bm::queue_sync< Value, Lock >::queue_type

protected

Definition at line 210 of file bmthreadpool.h.

## value_type

template<typename Value, typename Lock>

typedef Value bm::queue_sync< Value, Lock >::value_type

Definition at line 132 of file bmthreadpool.h.

## Constructor & Destructor Documentation

## queue_sync()

template<typename Value, typename Lock>

bm::queue_sync< Value, Lock >::queue_sync | ( |  | ) |

inline noexcept

constructor

Definition at line 137 of file bmthreadpool.h.

## Member Function Documentation

## empty()

template<typename Value, typename Lock>

bool bm::queue_sync< Value, Lock >::empty | ( |  | ) | const

inline

Returns
  true if empty

Definition at line 181 of file bmthreadpool.h.

## lock()

template<typename Value, typename Lock>

void bm::queue_sync< Value, Lock >::lock | ( |  | ) |

inline noexcept

lock the queue access

See also
  push_no_lock, unlock

Definition at line 189 of file bmthreadpool.h.

## push()

template<typename Value, typename Lock>

void bm::queue_sync< Value, Lock >::push | ( | const value_type & | v | ) |

inline

Push value to the back of the queue.

Parameters

  v | - value to put in the queue

See also
  push_no_lock

Definition at line 144 of file bmthreadpool.h.

## push_no_lock()

template<typename Value, typename Lock>

void bm::queue_sync< Value, Lock >::push_no_lock | ( | const value_type & | v | ) |

inline

Push value to the back of the queue without lock protection It is assumed that processing did not start and we are just staging the batch.

Parameters

  v | - value to put in the queue

See also
  push

Definition at line 160 of file bmthreadpool.h.

## try_lock()

template<typename Value, typename Lock>

bool bm::queue_sync< Value, Lock >::try_lock | ( |  | ) |

inline noexcept

Try to lock the queue exclusively.

Definition at line 194 of file bmthreadpool.h.

## try_pop()

template<typename Value, typename Lock>

bool bm::queue_sync< Value, Lock >::try_pop | ( | value_type & | v | ) |

inline

Extract value.

Parameters

  v | - [out] value returned

Returns
  true if extracted

Definition at line 170 of file bmthreadpool.h.

## unlock()

template<typename Value, typename Lock>

void bm::queue_sync< Value, Lock >::unlock | ( |  | ) |

inline noexcept

unlock the queue access

See also
  push_no_lock, lock

Definition at line 199 of file bmthreadpool.h.

## Friends And Related Symbol Documentation

## bm::thread_pool

template<typename Value, typename Lock>
template<typename QV, typename L>

friend class bm::thread_pool

friend

Definition at line 207 of file bmthreadpool.h.

## Field Documentation

## queue_push_cond_

template<typename Value, typename Lock>

std::condition_variable bm::queue_sync< Value, Lock >::queue_push_cond_

protected

mutex paired conditional

Definition at line 222 of file bmthreadpool.h.

## signal_mut_

template<typename Value, typename Lock>

std::mutex bm::queue_sync< Value, Lock >::signal_mut_

mutable protected

signal mutex for q submissions

Definition at line 221 of file bmthreadpool.h.

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

- bmthreadpool.h