Ocean
Ocean::WorkerPool::ScopedWorker Class Reference

Definition of scoped worker object. More...

Public Member Functions

 ScopedWorker ()=default
 Creates an empty scoped worker object. More...
 
 ScopedWorker (ScopedWorker &&object) noexcept
 Move constructor. More...
 
 ScopedWorker (Worker *worker) noexcept
 Creates a new scoped worker object. More...
 
 ~ScopedWorker ()
 Destructs a scoped worker object and unlocks the internal worker object automatically. More...
 
Workerworker () const
 Returns the internal worker object. More...
 
void release ()
 Explicitly releases the object and does not wait until the scope ends. More...
 
ScopedWorkeroperator= (ScopedWorker &&object) noexcept
 Move a scoped worker object. More...
 
Workeroperator() () const
 Returns the internal worker object. More...
 
 operator bool () const
 Returns whether this scoped objects holds an internal worker object. More...
 

Private Member Functions

 ScopedWorker (const ScopedWorker &scopedWorker)=delete
 Disabled copy constructor. More...
 
ScopedWorkeroperator= (const ScopedWorker &scopedWorker)=delete
 Disabled copy operator. More...
 

Private Attributes

Workerworker_ = nullptr
 Internal worker object. More...
 

Detailed Description

Definition of scoped worker object.

Constructor & Destructor Documentation

◆ ScopedWorker() [1/4]

Ocean::WorkerPool::ScopedWorker::ScopedWorker ( )
default

Creates an empty scoped worker object.

◆ ScopedWorker() [2/4]

Ocean::WorkerPool::ScopedWorker::ScopedWorker ( ScopedWorker &&  object)
inlinenoexcept

Move constructor.

Parameters
objectThe object to move

◆ ScopedWorker() [3/4]

Ocean::WorkerPool::ScopedWorker::ScopedWorker ( Worker worker)
inlineexplicitnoexcept

Creates a new scoped worker object.

Parameters
workerThe worker object of this scoped object.

◆ ~ScopedWorker()

Ocean::WorkerPool::ScopedWorker::~ScopedWorker ( )
inline

Destructs a scoped worker object and unlocks the internal worker object automatically.

◆ ScopedWorker() [4/4]

Ocean::WorkerPool::ScopedWorker::ScopedWorker ( const ScopedWorker scopedWorker)
privatedelete

Disabled copy constructor.

Parameters
scopedWorkerObject which would be copied

Member Function Documentation

◆ operator bool()

Ocean::WorkerPool::ScopedWorker::operator bool ( ) const
inlineexplicit

Returns whether this scoped objects holds an internal worker object.

Returns
True, if so

◆ operator()()

Worker * Ocean::WorkerPool::ScopedWorker::operator() ( ) const
inline

Returns the internal worker object.

Beware: Do not store this object outside this scoped object. The internal object will exist as long this scoped objects exist.

Returns
Worker object of this scoped object

◆ operator=() [1/2]

ScopedWorker& Ocean::WorkerPool::ScopedWorker::operator= ( const ScopedWorker scopedWorker)
privatedelete

Disabled copy operator.

Parameters
scopedWorkerObject which would be copied
Returns
Reference to this object

◆ operator=() [2/2]

WorkerPool::ScopedWorker & Ocean::WorkerPool::ScopedWorker::operator= ( ScopedWorker &&  object)
inlinenoexcept

Move a scoped worker object.

Parameters
objectThe object to move
Returns
Reference to this object

◆ release()

void Ocean::WorkerPool::ScopedWorker::release ( )
inline

Explicitly releases the object and does not wait until the scope ends.

The internal worker object will be returned to the worker pool and cannot be accessed anymore by this object.

◆ worker()

Worker * Ocean::WorkerPool::ScopedWorker::worker ( ) const
inline

Returns the internal worker object.

Beware: Do not store this object outside this scoped object. The internal object will exist as long this scoped objects exist.

Returns
Worker object of this scoped object

Field Documentation

◆ worker_

Worker* Ocean::WorkerPool::ScopedWorker::worker_ = nullptr
private

Internal worker object.


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