libfilezilla
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Public Member Functions | Protected Member Functions | Friends
thread Class Reference

Spawns and represents a new thread of execution. More...

#include <thread.hpp>

Inheritance diagram for thread:
Inheritance graph
[legend]

List of all members.

Public Member Functions

virtual ~thread ()
 Calls std::abort if the thread has not been joined.
bool run ()
 Start the thread.
void join ()
 Join the thread.
bool joinable () const
 A thread is joinable after having been started and before it has been joined.

Protected Member Functions

virtual void entry ()=0
 The thread's entry point, override in your derived class.

Friends

class impl

Detailed Description

Spawns and represents a new thread of execution.

This is a replacement of std::thread. Unfortunately std::thread isn't implemented on all MinGW flavors. Most notably, MinGW as shipped by Debian Jessie does not have std::thread.

This class only supports joinable threads (see remark). You _MUST_ join threads in the destructor of the outermost derived class. ~thread() calls std::abort() if join has not previously been called.

Remarks:
Detached threads aren't implemented since they essentially race conditions by design. You cannot use a detached thread and shutdown your program cleanly.

Constructor & Destructor Documentation

virtual ~thread ( ) [virtual]

Calls std::abort if the thread has not been joined.

To avoid race conditions, all threads need to be joined no later than in the destructor of the most derived class.


Member Function Documentation

void join ( )

Join the thread.

join blocks until the spawn thread has quit.

You must call this at the latest in the destructor of the most-derived class.

Must not be called from the spawned thread.

After a successful join you can call run again to spawn another thread.

Reimplemented in final< UniqueType, Values >.

bool joinable ( ) const

A thread is joinable after having been started and before it has been joined.

Must not be called from the spawned thread.

bool run ( )

Start the thread.

If a thread has already been started and not yet joined, this function fails.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines