void *abaco (void *threadid)
that is used on pthread.void * File_list::test (void * test) { cout << "Testing..." << endl; } |
|
|
main.cpp|67|error: argument of type ‘void* (File_list::)(void*)’ does not match ‘void* (*)(void*)’| |
|
|
|
|
|
|
|
|
|
|
|
|
File_list ry;
thread_data td;
..rc = pthread_create (&threads[i], NULL, File_list::run_thread, &td);
|
|
static void* run_thread (void* ptr)
is now receiving a pointer to a structure thread_data
, no more a pointer to a File_list
instance, so to leave the "run_thread" code unaltered could unleash unexpected results? If the static cast is made to thread_data
it will not compile. If I want to pass the thread_id
member to the test member function, how I could do it? I guess it cannot be static_cast<File_list*>(ptr)->test(ptr->thread_id);
|
|
|
|
thread_data
on the main.cpp, before main ()
starts. I receive several complaints like these:|17|error: ISO C++ forbids declaration of ‘File_list’ with no type| |
|17|error: expected ‘;’ before ‘*’ token| |
|
|
|55|error: ‘File_list’ has not been declared| |
rc = pthread_create (&threads[i], NULL, File_list::run_thread, &td);
|65|error: ‘File_list’ was not declared in this scope| |
|65|error: ‘fl’ was not declared in this scope| |
File_list fl
#include "RayTracer.h"
on main.cpp and #ifndef #define #endif
directives on File_list.h
thread_data
is inside the File_list
class, I receive:|45|error: ‘thread_data’ was not declared in this scope| |
thread_data td;
, plus all the same complaints that I received on lines 55 e 65. And there is A #include "File_list.h"
on main.cpp
|
|
|
|
|
|
main() : creating thread, 0 main() : creating thread, 1 run_thread... test!, Thread id1 10 10 10 10 10 10 10 10 10 10 File_list::another_method Another_class::method_from_another_class: count: 0 test!, Thread id1 10 10 10 10 10 10 10 10 10 10 |
main() : creating thread, 0 main() : creating thread, 1 File_list::another_method Another_class::method_from_another_class: count: 0 run_thread... test!, Thread id1 10 10 10 10 10 10 10 10 10 10 run_thread... test!, Thread id1 10 10 10 10 10 10 10 10 10 10 |
main() : creating thread, 0 td.thread_index: 0 main() : creating thread, 1 td.thread_index: 1 run_thread... test!, Thread id1 10 10 10 10 10 10 10 10 10 10 File_list::another_method Another_class::method_from_another_class: count: 0 run_thread... test!, Thread id1 10 10 10 10 10 10 10 10 10 10 |
test!, Thread id0 5 5 5 5 5 5 5 5 5 5 |
|
|
|
|
|
|
|
|
main() : creating thread, 0 td_array.thread_index: 0 main() : creating thread, 1 td_array.thread_index: 1 run_thread... td->thread_index: 0 test!, Thread id0 Segmentation fault |
|
|
|
|
main() : creating thread, 0 td_array.thread_index: 0 main() : creating thread, 1 td_array.thread_index: run_thread...1 td->thread_index: 0 test!, Thread id0 fl.d[0]: 5 5 5 5 run_thread... td->thread_index: 1 test!, Thread id1fl.d[1]: 5 5 fl.d[2]: 55 fl.d[3]: 5 fl.d[4]: 0 5 fl.d[5]: 0 fl.d[6]: 4.85997e-08 10 10 fl.d[7]: 10 1010 fl.d[8]: 10 fl.d[9]: 10 5 5 5 5 5 10 10 10 10 10 |
main() : creating thread, 0 td_array.thread_index: 0 main() : creating thread, 1 td_array.thread_index: 1 run_thread... td->thread_index: 0 test!, Thread id0 fl.d[0]: 55 run_thread... td->thread_index: 1 test!, Thread id1 5 5 5 5 5 5 5 5 5 10 10 10 10 1010 10 10 10 10 fl.d[1]: 5 fl.d[2]: 5 fl.d[3]: 5 fl.d[4]: 5 fl.d[5]: 10 fl.d[6]: 10 fl.d[7]: 10 fl.d[8]: 10 fl.d[9]: 10 |
fl.d[7]: 10 1010 |
fl.d[0]: 55 |
join
now to try to keep things synchronized, or there still is something wrong with my code?