This commit is contained in:
lasnier 2012-12-05 17:05:00 +01:00
commit f8d2d1cfa5
21 changed files with 452 additions and 406 deletions

View file

@ -17,7 +17,6 @@ set(LIBRARY_OUTPUT_PATH ${SMP_LIB_OUTPUT_PATH})
######################################################################################
set (SMP_FILE
thread.cpp
MWModel.h
scheduler.h
island.h
@ -29,6 +28,7 @@ set (SMP_FILE
topology/ring.cpp
topology/hypercubic.cpp
topology/mesh.cpp
notifier.cpp
)
add_library(smp STATIC ${SMP_FILE})
@ -46,7 +46,7 @@ install(FILES ${HDRS} DESTINATION include${INSTALL_SUB_DIR}/smp COMPONENT header
### 4) Install directories
######################################################################################
install(DIRECTORY MWAlgo
install(DIRECTORY MWAlgo topology
DESTINATION include${INSTALL_SUB_DIR}/smp
COMPONENT headers
FILES_MATCHING PATTERN "*.h"

View file

@ -39,7 +39,7 @@ paradiseo::smp::MWModel<EOAlgo,EOT,Policy>::MWModel(unsigned workersNb, Args&...
template<template <class> class EOAlgo, class EOT, class Policy>
template<class... Args>
paradiseo::smp::MWModel<EOAlgo,EOT,Policy>::MWModel(Args&... args) :
MWModel(Thread::hardware_concurrency(), args...)
MWModel(std::thread::hardware_concurrency(), args...)
{}
template<template <class> class EOAlgo, class EOT, class Policy>

View file

@ -31,6 +31,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#define MWMODEL_H_
#include <cassert>
#include <thread>
#include <scheduler.h>
#include <algoDispatching.h>
@ -113,7 +114,7 @@ protected:
*/
void operator()(eoPop<EOT>& pop,const error_tag&);
std::vector<Thread*> workers;
std::vector<std::thread*> workers;
Scheduler<EOT,Policy> scheduler;
};

View file

@ -51,7 +51,7 @@ The abstract island is used to manipulate island pointers wihout the knowledge o
@see smp::Island
*/
template<class EOT>
template<class bEOT>
class AIsland
{
public:
@ -61,18 +61,7 @@ public:
/**
* Check if there is population to receive
*/
virtual void setModel(IslandModel<EOT>* _model) = 0;
/**
* Send population to mediator
* @param _select Method to select EOT to send
*/
virtual void send(eoSelect<EOT>& _select) = 0;
/**
* Check if there is population to receive
*/
virtual void receive(void) = 0;
virtual void setModel(IslandModel<bEOT>* _model) = 0;
/**
* Check if there is population to receive or to emigrate
@ -82,13 +71,15 @@ public:
/**
* Update the island by adding population to send in the imigrants list.
*/
virtual void update(eoPop<EOT> _data) = 0;
virtual void update(eoPop<bEOT> _data) = 0;
/**
* Check if the algorithm is stopped.
* @return true if stopped
*/
virtual bool isStopped(void) const = 0;
virtual void receive(void) = 0;
protected:
std::mutex m;

View file

@ -28,7 +28,7 @@ Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef BIMAP_MODEL_H_
#define BIMAP_H_
#define BIMAP_MODEL_H_
#include <set>
#include <map>

View file

@ -27,10 +27,10 @@ ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
template<class EOT>
paradiseo::smp::ContWrapper<EOT>::ContWrapper(eoContinue<EOT>& _cont, AIsland<EOT>* island) :
template<class EOT, class bEOT>
paradiseo::smp::ContWrapper<EOT, bEOT>::ContWrapper(eoContinue<EOT>& _cont, AIsland<bEOT>* island) :
ck(_cont),
islandNotifier(island, &AIsland<EOT>::check)
islandNotifier(island, &AIsland<bEOT>::check)
{
ck.add(islandNotifier);
}

View file

@ -50,7 +50,7 @@ By using the wrapper, we do not have to modify original continuators inside the
it avoids some side effects.
*/
template<class EOT>
template<class EOT, class bEOT>
class ContWrapper
{
public:
@ -59,11 +59,11 @@ public:
* @param _cont Original continuators
* @param _policy Policy to wrap with continuators
*/
ContWrapper(eoContinue<EOT>& _cont, AIsland<EOT>* island);
ContWrapper(eoContinue<EOT>& _cont, AIsland<bEOT>* island);
protected:
eoCheckPoint<EOT> ck;
IslandNotifier<EOT> islandNotifier;
IslandNotifier<bEOT> islandNotifier;
};
#include <contWrapper.cpp>

View file

@ -27,12 +27,12 @@ ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
template<template <class> class EOAlgo, class EOT>
template<template <class> class EOAlgo, class EOT, class bEOT>
template<class... Args>
paradiseo::smp::Island<EOAlgo,EOT>::Island(eoPop<EOT>& _pop, IntPolicy<EOT>& _intPolicy, MigPolicy<EOT>& _migPolicy, Args&... args) :
paradiseo::smp::Island<EOAlgo,EOT,bEOT>::Island(std::function<EOT(bEOT&)> _convertFromBase, std::function<bEOT(EOT&)> _convertToBase, eoPop<EOT>& _pop, IntPolicy<EOT>& _intPolicy, MigPolicy<EOT>& _migPolicy, Args&... args) :
// The PPExpander looks for the continuator in the parameters pack.
// The private inheritance of ContWrapper wraps the continuator and add islandNotifier.
ContWrapper<EOT>(Loop<Args...>().template findValue<eoContinue<EOT>>(args...), this),
ContWrapper<EOT, bEOT>(Loop<Args...>().template findValue<eoContinue<EOT>>(args...), this),
// We inject the wrapped continuator by tag dispatching method during the algorithm construction.
algo(EOAlgo<EOT>(wrap_pp<eoContinue<EOT>>(this->ck,args)...)),
// With the PPE we look for the eval function in order to evaluate EOT to integrate
@ -41,14 +41,26 @@ paradiseo::smp::Island<EOAlgo,EOT>::Island(eoPop<EOT>& _pop, IntPolicy<EOT>& _in
intPolicy(_intPolicy),
migPolicy(_migPolicy),
stopped(false),
model(nullptr)
model(nullptr),
convertFromBase(_convertFromBase),
convertToBase(_convertToBase)
{
// Check in compile time the inheritance thanks to type_trait.
static_assert(std::is_base_of<eoAlgo<EOT>,EOAlgo<EOT>>::value, "Algorithm must inherit from eoAlgo<EOT>");
}
template<template <class> class EOAlgo, class EOT>
void paradiseo::smp::Island<EOAlgo,EOT>::operator()()
template<template <class> class EOAlgo, class EOT, class bEOT>
template<class... Args>
paradiseo::smp::Island<EOAlgo,EOT,bEOT>::Island(eoPop<EOT>& _pop, IntPolicy<EOT>& _intPolicy, MigPolicy<EOT>& _migPolicy, Args&... args) :
Island(
// Default conversion functions for homogeneous islands
[](bEOT& i) -> EOT { return std::forward<EOT>(i); },
[](EOT& i) -> bEOT { return std::forward<bEOT>(i); },
_pop, _intPolicy, _migPolicy, args...)
{ }
template<template <class> class EOAlgo, class EOT, class bEOT>
void paradiseo::smp::Island<EOAlgo,EOT,bEOT>::operator()()
{
stopped = false;
algo(pop);
@ -58,20 +70,20 @@ void paradiseo::smp::Island<EOAlgo,EOT>::operator()()
message.join();
}
template<template <class> class EOAlgo, class EOT>
void paradiseo::smp::Island<EOAlgo,EOT>::setModel(IslandModel<EOT>* _model)
template<template <class> class EOAlgo, class EOT, class bEOT>
void paradiseo::smp::Island<EOAlgo,EOT,bEOT>::setModel(IslandModel<bEOT>* _model)
{
model = _model;
}
template<template <class> class EOAlgo, class EOT>
eoPop<EOT>& paradiseo::smp::Island<EOAlgo,EOT>::getPop()
template<template <class> class EOAlgo, class EOT, class bEOT>
eoPop<EOT>& paradiseo::smp::Island<EOAlgo,EOT,bEOT>::getPop()
{
return pop;
}
template<template <class> class EOAlgo, class EOT>
void paradiseo::smp::Island<EOAlgo,EOT>::check()
template<template <class> class EOAlgo, class EOT, class bEOT>
void paradiseo::smp::Island<EOAlgo,EOT,bEOT>::check()
{
// Sending
for(PolicyElement<EOT>& elem : migPolicy)
@ -82,37 +94,50 @@ void paradiseo::smp::Island<EOAlgo,EOT>::check()
receive();
}
template<template <class> class EOAlgo, class EOT>
bool paradiseo::smp::Island<EOAlgo,EOT>::isStopped(void) const
template<template <class> class EOAlgo, class EOT, class bEOT>
bool paradiseo::smp::Island<EOAlgo,EOT,bEOT>::isStopped(void) const
{
return (bool)stopped;
}
template<template <class> class EOAlgo, class EOT>
void paradiseo::smp::Island<EOAlgo,EOT>::send(eoSelect<EOT>& _select)
template<template <class> class EOAlgo, class EOT, class bEOT>
void paradiseo::smp::Island<EOAlgo,EOT,bEOT>::send(eoSelect<EOT>& _select)
{
// Allow island to work alone
if(model != nullptr)
{
eoPop<EOT> migPop;
_select(pop, migPop);
// Convert pop to base pop
eoPop<bEOT> baseMigPop;
for(auto& indi : migPop)
baseMigPop.push_back(convertToBase(indi));
//std::cout << "On envoie de l'île : " << migPop << std::endl;
// Delete delivered messages
for(auto it = sentMessages.begin(); it != sentMessages.end(); it++)
if(!it->joinable())
sentMessages.erase(it);
sentMessages.push_back(std::thread(&IslandModel<EOT>::update, model, migPop, this));
sentMessages.push_back(std::thread(&IslandModel<bEOT>::update, model, baseMigPop, this));
}
}
template<template <class> class EOAlgo, class EOT>
void paradiseo::smp::Island<EOAlgo,EOT>::receive(void)
template<template <class> class EOAlgo, class EOT, class bEOT>
void paradiseo::smp::Island<EOAlgo,EOT,bEOT>::receive(void)
{
std::lock_guard<std::mutex> lock(this->m);
while (!listImigrants.empty())
{
eoPop<EOT> offspring = listImigrants.front();
//std::cout << "On reçoit dans l'île : " << listImigrants.size() << std::endl;
eoPop<bEOT> base_offspring = listImigrants.front();
// Convert objects from base to our objects type
eoPop<EOT> offspring;
for(auto& indi : base_offspring)
offspring.push_back(convertFromBase(indi));
// Evaluate objects to integrate
for(auto& indi : offspring)
@ -124,9 +149,10 @@ void paradiseo::smp::Island<EOAlgo,EOT>::receive(void)
}
}
template<template <class> class EOAlgo, class EOT>
void paradiseo::smp::Island<EOAlgo,EOT>::update(eoPop<EOT> _data)
template<template <class> class EOAlgo, class EOT, class bEOT>
void paradiseo::smp::Island<EOAlgo,EOT,bEOT>::update(eoPop<bEOT> _data)
{
//std::cout << "On update dans l'île" << std::endl;
std::lock_guard<std::mutex> lock(this->m);
listImigrants.push(_data);
}

View file

@ -60,10 +60,22 @@ The island wraps an algorithm and provide mecanism for emigration and integratio
@see smp::AbstractIsland, smp::MigPolicy
*/
template<template <class> class EOAlgo, class EOT>
class Island : private ContWrapper<EOT>, public AIsland<EOT>
template<template <class> class EOAlgo, class EOT, class bEOT = EOT>
class Island : private ContWrapper<EOT, bEOT>, public AIsland<bEOT>
{
public:
/**
* Constructor
* @param _convertFromBase Function to convert EOT from base EOT
* @param _convertToBase Function to convert base EOT to EOT
* @param _popSize Size of the algorithm population.
* @param _chromInit Population initializer.
* @param _intPolicy Integration policy
* @param _migPolicy Migration policy
* @param args Parameters to construct the algorithm.
*/
template<class... Args>
Island(std::function<EOT(bEOT&)> _convertFromBase, std::function<bEOT(EOT&)> _convertToBase, eoPop<EOT>& pop, IntPolicy<EOT>& _intPolicy, MigPolicy<EOT>& _migPolicy, Args&... args);
/**
* Constructor
* @param _popSize Size of the algorithm population.
@ -84,7 +96,7 @@ public:
* Set model
* @param _model Pointer to the Island Model corresponding
*/
virtual void setModel(IslandModel<EOT>* _model);
virtual void setModel(IslandModel<bEOT>* _model);
/**
* Return a reference to the island population.
@ -101,7 +113,7 @@ public:
* Update the list of imigrants.
* @param _data Elements to integrate in the main population.
*/
void update(eoPop<EOT> _data);
void update(eoPop<bEOT> _data);
/**
* Check if the algorithm is stopped.
@ -109,6 +121,11 @@ public:
*/
virtual bool isStopped(void) const;
/**
* Check if there is population to receive
*/
virtual void receive(void);
protected:
/**
@ -117,20 +134,17 @@ protected:
*/
virtual void send(eoSelect<EOT>& _select);
/**
* Check if there is population to receive
*/
virtual void receive(void);
eoEvalFunc<EOT>& eval;
eoPop<EOT>& pop;
EOAlgo<EOT> algo;
std::queue<eoPop<EOT>> listImigrants;
std::queue<eoPop<bEOT>> listImigrants;
IntPolicy<EOT>& intPolicy;
MigPolicy<EOT>& migPolicy;
std::atomic<bool> stopped;
std::vector<std::thread> sentMessages;
IslandModel<EOT>* model;
IslandModel<bEOT>* model;
std::function<EOT(bEOT&)> convertFromBase;
std::function<bEOT(EOT&)> convertToBase;
};
#include <island.cpp>

View file

@ -48,18 +48,12 @@ void paradiseo::smp::IslandModel<EOT>::operator()()
{
running = true;
// INIT PART
// Create topology, table and initialize islands
initModel();
std::vector<std::thread> threads(islands.size());
// Preparing islands
for(auto it : islands)
it.second = true;
// Construct topology according to the number of islands
topo.construct(islands.size());
// Create table
table = createTable();
// Launching threads
unsigned i = 0;
for(auto it : islands)
@ -68,14 +62,15 @@ void paradiseo::smp::IslandModel<EOT>::operator()()
i++;
}
//
// Lambda function in order to know the number of working islands
std::function<int()> workingIslands = [this]() -> int
{
return (int)std::count_if(std::begin(islands), std::end(islands),
[](std::pair<AIsland<EOT>*, bool>& i) -> bool
{ return i.second; } );
};
// SCHEDULING PART
while(workingIslands() > 0)
{
// Count working islands
@ -93,13 +88,29 @@ void paradiseo::smp::IslandModel<EOT>::operator()()
std::this_thread::sleep_for(std::chrono::nanoseconds(10));
}
// ENDING PART
// Wait the end of algorithms
for(auto& thread : threads)
thread.join();
// Wait the end of messages sending
for(auto& message : sentMessages)
message.join();
// Force last integration
i = 0;
for(auto it : islands)
{
threads[i] = std::thread(&AIsland<EOT>::receive, it.first);
i++;
}
// Wait the end of the last integration
for(auto& thread : threads)
thread.join();
running = false;
}
@ -107,6 +118,7 @@ template<class EOT>
void paradiseo::smp::IslandModel<EOT>::update(eoPop<EOT> _data, AIsland<EOT>* _island)
{
std::lock_guard<std::mutex> lock(m);
//std::cout << "Mediateur reçoit ! " << _data << std::endl;
listEmigrants.push(std::pair<eoPop<EOT>,AIsland<EOT>*>(_data, _island));
}
@ -119,6 +131,7 @@ void paradiseo::smp::IslandModel<EOT>::setTopology(AbstractTopology& _topo)
// If we change when the algorithm is running, we need to recontruct the topo
if(running)
{
std::cout << "Changing topology" << std::endl;
topo.construct(islands.size());
// If we change the topology during the algorithm, we need to isolate stopped islands
for(auto it : islands)
@ -131,8 +144,9 @@ template<class EOT>
void paradiseo::smp::IslandModel<EOT>::send(void)
{
std::lock_guard<std::mutex> lock(m);
while (!listEmigrants.empty())
if (!listEmigrants.empty())
{
//std::cout << "Mediator envoie ! " << listEmigrants.size() << std::endl;
// Get the neighbors
unsigned idFrom = table.getLeft()[listEmigrants.front().second];
std::vector<unsigned> neighbors = topo.getIdNeighbors(idFrom);
@ -146,6 +160,26 @@ void paradiseo::smp::IslandModel<EOT>::send(void)
}
}
template<class EOT>
bool paradiseo::smp::IslandModel<EOT>::isRunning() const
{
return (bool)running;
}
template<class EOT>
void paradiseo::smp::IslandModel<EOT>::initModel(void)
{
// Preparing islands
for(auto& it : islands)
it.second = true; // Indicate islands are active
// Construct topology according to the number of islands
topo.construct(islands.size());
// Create table
table = createTable();
}
template<class EOT>
Bimap<unsigned, AIsland<EOT>*> paradiseo::smp::IslandModel<EOT>::createTable()
{
@ -159,9 +193,3 @@ Bimap<unsigned, AIsland<EOT>*> paradiseo::smp::IslandModel<EOT>::createTable()
return table;
}
template<class EOT>
bool paradiseo::smp::IslandModel<EOT>::isRunning() const
{
return (bool)running;
}

View file

@ -52,6 +52,8 @@ island model pattern according to a topology.
@see smp::Island, smp::MigPolicy
*/
template<class EOT>
class IslandModel
{
@ -89,6 +91,11 @@ protected:
*/
void send(void);
/**
* Initialize islands, topology and table before starting the model
*/
void initModel(void);
Bimap<unsigned, AIsland<EOT>*> createTable();
std::queue<std::pair<eoPop<EOT>,AIsland<EOT>*>> listEmigrants;

View file

@ -27,8 +27,6 @@ ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <typeinfo>
template<class EOT, class Policy>
paradiseo::smp::Scheduler<EOT,Policy>::Scheduler(unsigned workersNb) :
workers(workersNb),
@ -75,7 +73,7 @@ void paradiseo::smp::Scheduler<EOT,Policy>::operator()(eoUF<EOT&, void>& func, e
// Starting threads
for(unsigned i = 0; i < workers.size(); i++)
workers[i].start(&Scheduler<EOT,Policy>::applyLinearPolicy, this, std::ref(func), std::ref(popPackages[i]));
workers[i] = std::thread(&Scheduler<EOT,Policy>::applyLinearPolicy, this, std::ref(func), std::ref(popPackages[i]));
// Wait the end of tasks
for(unsigned i = 0; i < workers.size(); i++)
@ -90,7 +88,7 @@ void paradiseo::smp::Scheduler<EOT,Policy>::operator()(eoUF<EOT&, void>& func, e
for(unsigned i = 0; i < workers.size(); i++)
{
planning[i] = 2;
workers[i].start(&Scheduler<EOT,Policy>::applyProgressivePolicy, this, std::ref(func), std::ref(popPackages[i]), i);
workers[i] = std::thread(&Scheduler<EOT,Policy>::applyProgressivePolicy, this, std::ref(func), std::ref(popPackages[i]), i);
}
unsigned counter = 0;

View file

@ -35,7 +35,6 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#include <atomic>
#include <mutex>
#include <thread.h>
#include <policiesDispatching.h>
#include <eoEvalFunc.h>
@ -106,7 +105,7 @@ protected:
*/
std::vector<std::vector<EOT*>> subGroups(eoPop<EOT>& pop);
std::vector<Thread> workers;
std::vector<std::thread> workers;
std::vector<std::vector<EOT*>> popPackages;
std::atomic<bool> done;

View file

@ -30,15 +30,16 @@ Contact: paradiseo-help@lists.gforge.inria.fr
#ifndef SMP_H
#define SMP_H
#include <thread.h>
#include <MWModel.h>
#include <scheduler.h>
#include <islandModel.h>
#include <island.h>
#include <abstractIsland.h>
#include <migPolicy.h>
#include <intPolicy.h>
#include <policyElement.h>
#include <islandNotifier.h>
#include <notifier.h>
// Topologies
#include <topology/topology.h>

View file

@ -1,73 +0,0 @@
/*
<thread.cpp>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
Alexandre Quemy
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#include <algorithm>
#include <utility>
#include <thread.h>
namespace paradiseo
{
namespace smp
{
Thread::Thread(Thread&& other)
{
t = std::move(other.t);
}
Thread& Thread::operator=(Thread&& other)
{
t = std::move(other.t);
return *this;
}
const std::thread::id paradiseo::smp::Thread::getId() const
{
return t.get_id();
}
bool paradiseo::smp::Thread::joinable() const
{
return t.joinable();
}
void paradiseo::smp::Thread::join()
{
t.join();
}
int paradiseo::smp::Thread::hardware_concurrency()
{
return std::thread::hardware_concurrency();
}
}
}

View file

@ -1,112 +0,0 @@
/*
<thread.h>
Copyright (C) DOLPHIN Project-Team, INRIA Lille - Nord Europe, 2006-2012
Alexandre Quemy
This software is governed by the CeCILL license under French law and
abiding by the rules of distribution of free software. You can ue,
modify and/ or redistribute the software under the terms of the CeCILL
license as circulated by CEA, CNRS and INRIA at the following URL
"http://www.cecill.info".
In this respect, the user's attention is drawn to the risks associated
with loading, using, modifying and/or developing or reproducing the
software by the user in light of its specific status of free software,
that may mean that it is complicated to manipulate, and that also
therefore means that it is reserved for developers and experienced
professionals having in-depth computer knowledge. Users are therefore
encouraged to load and test the software's suitability as regards their
requirements in conditions enabling the security of their systems and/or
data to be ensured and, more generally, to use and operate it in the
same conditions as regards security.
The fact that you are presently reading this means that you have had
knowledge of the CeCILL license and that you accept its terms.
ParadisEO WebSite : http://paradiseo.gforge.inria.fr
Contact: paradiseo-help@lists.gforge.inria.fr
*/
#ifndef THREAD_H_
#define THREAD_H_
#include <iostream>
#include <thread>
#include <vector>
namespace paradiseo
{
namespace smp
{
/**
A thread class which encapsulate the std::thread behaviour for more flexibility
@see smp::Worker, smp::MWModel
*/
class Thread
{
public:
/**
* Default constructor
*/
Thread() = default;
/**
* Constructor that will immediatly start the thread
* @param f represente any callable object such as function or class method
* @param args... reference object and parameters for f
*/
template< class Callable, class... Args >
explicit Thread(Callable&& f, Args&&... args) : t(std::thread(std::forward<Callable>(f), std::forward<Args>(args)...)) {}
Thread(Thread&& other);
Thread(const Thread&) = delete;
Thread& operator=(const Thread&) = delete;
virtual ~Thread() = default;
Thread& operator=(Thread&& other);
/**
* Start the thread according to parameters
* If the thread is running, it will wait until the end of its task
* @param f represente any callable object such as function or class method
* @param args... reference object and parameters for f
*/
template<class Callable,class... Args>
void start(Callable&& f,Args&&... args);
/**
* Get the id of the thread
* @return id of the thread
*/
const std::thread::id getId() const;
/**
* Get the state of the thread
* @return true if the thread is running, false otherwise
*/
bool joinable() const;
/**
* Wait until the end of the task
*/
void join();
static int hardware_concurrency();
protected:
std::thread t;
};
template<class Callable,class... Args>
void paradiseo::smp::Thread::start(Callable&& f,Args&&... args)
{
t = std::thread(std::forward<Callable>(f), std::forward<Args>(args)...);
}
}
}
#endif /*THREAD_H_*/