Test mutexes and threading capabilities.
#include <iostream>
#include <visp3/core/vpMutex.h>
#include <visp3/core/vpThread.h>
#if defined(VISP_HAVE_PTHREAD) || (defined(_WIN32) && !defined(WINRT_8_0))
int thread_counter = 0;
{
unsigned int thread_id = *((unsigned int *)args);
std::cout << "Started job " << thread_counter << " with id " << thread_id << std::endl;
for (unsigned long i = 0; i < (0xFFFF); i++) {
};
std::cout << "Ended job " << thread_counter << std::endl;
thread_counter++;
return 0;
}
int main(void)
{
unsigned int nthread = 10;
unsigned int *thread_id = new unsigned int[nthread];
for (unsigned int i = 0; i < nthread; i++) {
thread_id[i] = i;
}
delete[] thread;
delete[] thread_id;
return 0;
}
#else
int main()
{
#if !defined(_WIN32) && (defined(__unix__) || defined(__unix) || (defined(__APPLE__) && defined(__MACH__))) // UNIX
std::cout << "You should enable pthread usage and rebuild ViSP..." << std::endl;
#else
std::cout << "Multi-threading seems not supported on this platform" << std::endl;
#endif
}
#endif