[Boost.Thread] Exécuter un thread avec une fonction membre
Bonjour à tous !
J'aimerai bien utiliser des Thread pour générer un film, afin que mon application puisse continuer à tourner, même si le calcul est assez "gourmand".
Le truc, c'est que
Code:
boost::thread my_thread(&genererFilm);
ne prend pas d'arguments, et pas de fonctions membres non static. :aie:
Mon code original est:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| void Camera::genererFilm(int image_debut, int image_fin, std::string nom_fichier)
{
std::cout << "Generation d'un film en cours..." << std::endl;
std::ofstream file ( nom_fichier.c_str(), std::ios_base::binary);
for (int i = image_debut; i < image_fin; i++) {
if (isNumeroValide(i) ) {
vigra::UInt16Image image = getImage(i);
vigra::UInt16Image::const_iterator iter;
for (iter = image.begin(); iter != image.end(); iter++) {
file.write(reinterpret_cast<const char*>(iter), sizeof(vigra::UInt16));
}
}
}
} |
En vert : les fonctions membres (non static)
En orange: les paramètres passés à la fonction (attributs non membres)
Je retourne le problème dans tous les sens, et je n'arrive pas à écrire quelquechose comme ça:
Code:
1 2 3 4
| void Camera::CreerFilm(int image_debut, int image_fin, std::string nom_fichier)
{
boost::thread my_thread(&genererFilm);
} |
Avez vous une astuce, une idée ?
:merci: