Beispiel #1
0
void do_test(M* dummy=0)
{
    typedef buffer_t<M> buffer_type;
    buffer_type::get_buffer();
    boost::thread thrd1(&buffer_type::do_receiver_thread);
    boost::thread thrd2(&buffer_type::do_receiver_thread);
    boost::thread thrd3(&buffer_type::do_sender_thread);
    thrd1.join();
    thrd2.join();
    thrd3.join();
}
Beispiel #2
0
int main(int, char*[])
{
    boost::thread thrd1(&sender);
    boost::thread thrd2(&receiver);
    boost::thread thrd3(&receiver);
    boost::thread thrd4(&receiver);
    thrd1.join();
    thrd2.join();
    thrd3.join();
    thrd4.join();
    return 0;
}
Beispiel #3
0
int main() {
  printf("\n============== sizeof(boost::thread) ============== %d\n", sizeof(boost::thread));
  printf("\n============== sizeof(boost::detail::thread_data_base) ============== %d\n", sizeof(boost::detail::thread_data_base));
  printf("\n============== sizeof(boost::detail::thread_data<>) ============== %d\n", sizeof(boost::detail::thread_data<void(*)()>));
  printf("\n============== Before thread creation ==============\n");
  display_mallinfo();
  {
    boost::thread thrd1(&count);

    printf("\n============== After thread creation ==============\n");
    display_mallinfo();

    boost::thread thrd2(&count);
    printf("\n============== After thread creation ==============\n");
    display_mallinfo();
    boost::thread thrd3(&count);
    printf("\n============== After thread creation ==============\n");
    display_mallinfo();

    thrd1.join();
    printf("\n============== After thread join ==============\n");
    display_mallinfo();

    thrd2.join();
    printf("\n============== After thread join ==============\n");
    display_mallinfo();
    thrd3.join();
    printf("\n============== After thread join ==============\n");
    display_mallinfo();
  }
  printf("\n============== After thread destruction ==============\n");
  display_mallinfo();

  {
    pthread_attr_t attr;
    pthread_attr_init(&attr);

    pthread_t thrd1;
    pthread_create(&thrd1, &attr, &count2, 0);
    printf("\n============== After thread creation ==============\n");
    display_mallinfo();

    pthread_t thrd2;
    pthread_create(&thrd2, &attr, &count2, 0);
    printf("\n============== After thread creation ==============\n");
    display_mallinfo();

    pthread_t thrd3;
    pthread_create(&thrd3, &attr, &count2, 0);
    printf("\n============== After thread creation ==============\n");
    display_mallinfo();

    pthread_attr_destroy(&attr);
    printf("\n============== After thread attr destroy ==============\n");
    display_mallinfo();

    void* res;
    pthread_join(thrd3, &res);
    printf("\n============== After thread join ==============\n");
    display_mallinfo();

    pthread_join(thrd2, &res);
    printf("\n============== After thread join ==============\n");
    display_mallinfo();
    pthread_join(thrd1, &res);
    printf("\n============== After thread join ==============\n");
    display_mallinfo();



    //pthread_destroy(&thrd1);
    //pthread_destroy(&thrd2);
    //pthread_destroy(&thrd3);
  }
  printf("\n============== After thread destruction ==============\n");
  display_mallinfo();

    return 1;

}