Scroom  0.14
ThreadPool::WeakQueue Class Reference

#include <threadpool.hh>

Collaboration diagram for ThreadPool::WeakQueue:
Collaboration graph

Public Types

using Ptr = boost::shared_ptr< WeakQueue >
 
using WeakPtr = boost::weak_ptr< WeakQueue >
 

Public Member Functions

 ~WeakQueue ()=default
 
 WeakQueue (const WeakQueue &)=delete
 
 WeakQueue (WeakQueue &&)=delete
 
WeakQueueoperator= (const WeakQueue &)=delete
 
WeakQueueoperator= (WeakQueue &&)=delete
 
boost::shared_ptr< Scroom::Detail::ThreadPool::QueueImplget ()
 

Static Public Member Functions

static Ptr create ()
 ThreadPool::WeakQueue. More...
 

Private Member Functions

 WeakQueue ()
 

Private Attributes

boost::shared_ptr< Scroom::Detail::ThreadPool::QueueImplqi
 

Detailed Description

Represent a weak Queue reference ThreadPool.

On occasion, you want tasks that are running on the ThreadPool to reschedule themselves. However, if tasks have a reference to their queue, you might risk a deadlock. If a tasks holds the last reference to the queue, then on task destruction, the queue will be destroyed. However, destroying the queue blocks for the task to finish.

As a way out of this, we introduce the WeakQueue, which can be used to schedule tasks, but does not contribute towards keeping the queue alive. I.e. If you destroy the last reference to a Queue, you can still use the associated WeakQueue to schedule tasks, but they will no longer be executed, because the Queue no longer exists.

See also
Queue

Member Typedef Documentation

◆ Ptr

using ThreadPool::WeakQueue::Ptr = boost::shared_ptr<WeakQueue>

◆ WeakPtr

using ThreadPool::WeakQueue::WeakPtr = boost::weak_ptr<WeakQueue>

Constructor & Destructor Documentation

◆ ~WeakQueue()

ThreadPool::WeakQueue::~WeakQueue ( )
default

◆ WeakQueue() [1/3]

ThreadPool::WeakQueue::WeakQueue ( const WeakQueue )
delete

◆ WeakQueue() [2/3]

ThreadPool::WeakQueue::WeakQueue ( WeakQueue &&  )
delete

◆ WeakQueue() [3/3]

ThreadPool::WeakQueue::WeakQueue ( )
private
399  : qi(QueueImpl::create())
400 {
401 }

Member Function Documentation

◆ create()

ThreadPool::WeakQueue::Ptr ThreadPool::WeakQueue::create ( )
static

◆ get()

QueueImpl::Ptr ThreadPool::WeakQueue::get ( )
403 { return qi; }

◆ operator=() [1/2]

WeakQueue& ThreadPool::WeakQueue::operator= ( const WeakQueue )
delete

◆ operator=() [2/2]

WeakQueue& ThreadPool::WeakQueue::operator= ( WeakQueue &&  )
delete

Member Data Documentation

◆ qi

boost::shared_ptr<Scroom::Detail::ThreadPool::QueueImpl> ThreadPool::WeakQueue::qi
private

The documentation for this class was generated from the following files:
ThreadPool::WeakQueue::Ptr
boost::shared_ptr< WeakQueue > Ptr
Definition: threadpool.hh:137
ThreadPool::WeakQueue
Definition: threadpool.hh:134
ThreadPool::WeakQueue::qi
boost::shared_ptr< Scroom::Detail::ThreadPool::QueueImpl > qi
Definition: threadpool.hh:155
create
void create(NewPresentationInterface *interface)
Definition: loader.cc:175