Bonjour,

j'ai une erreur bizarre que je ne comprend pas.

Je veux passer un vecteur de thread en argument à un nouveau thread.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 
bool threadTimer(std::vector<boost::thread> _thread, int _timer)
{
	bool isFinish = false;			// Check if threatement is finish.
	boost::timer timer;				// Get time for force close.
	boost::thread threadExecute = boost::thread(threadTimerJoin, _thread, &isFinish);
	// Busy waiting replace callback.
	while (!((isFinish) || (timer.elapsed() > _timer)))
	{
		usleep(100);
	}
 
	return isFinish ? true : false;
}
 
void threadTimerJoin(std::vector<boost::thread> _thread, bool* isFinish)
{
	for (std::vector<boost::thread>::iterator it = _thread.begin(); it != _thread.end(); ++it)
	{
		it->join();
	}
 
	*isFinish = true;
}
Et j'obtient l'erreur :
/usr/include/boost/bind/bind_template.hpp:20: instantiated from ‘typename boost::_bi::result_traits<R, F>::type boost::_bi::bind_t<R, F, L>::operator()() [with R = void, F = void (*)(std::vector<boost::thread, std::allocator<boost::thread> >, bool*), L = boost::_bi::list2<boost::_bi::value<std::vector<boost::thread, std::allocator<boost::thread> >*>, boost::_bi::value<bool*> >]’
/usr/include/boost/thread/detail/thread.hpp:56: instantiated from ‘void boost::detail::thread_data<F>::run() [with F = boost::_bi::bind_t<void, void (*)(std::vector<boost::thread, std::allocator<boost::thread> >, bool*), boost::_bi::list2<boost::_bi::value<std::vector<boost::thread, std::allocator<boost::thread> >*>, boost::_bi::value<bool*> > >]’
../../src/thread/ThreadTimer.cpp:41: instantiated from here
/usr/include/boost/bind/bind.hpp:306: error: conversion from ‘std::vector<boost::thread, std::allocator<boost::thread> >*’ to non-scalar type ‘std::vector<boost::thread, std::allocator<boost::thread> >’ requested
make: *** [build/debug/../../src/thread/ThreadTimer.o] Error 1

Erreur dont je comprends rien . Cela fonctionne si j'utilise des types primitifs, mais pas dès que je passe un vecteur.

Merci