]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/thread/test/test_8557.cpp
1 // Copyright (C) 2013 Vicente Botet
3 // Distributed under the Boost Software License, Version 1.0. (See accompanying
4 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 #include <boost/thread/thread.hpp>
11 #include <boost/thread/mutex.hpp>
13 #include <boost/bind.hpp>
24 printf("Total non-mmapped bytes (arena): %d\n", mi
.arena
);
25 printf("# of free chunks (ordblks): %d\n", mi
.ordblks
);
26 printf("# of free fastbin blocks (smblks): %d\n", mi
.smblks
);
27 printf("# of mapped regions (hblks): %d\n", mi
.hblks
);
28 printf("Bytes in mapped regions (hblkhd): %d\n", mi
.hblkhd
);
29 printf("Max. total allocated space (usmblks): %d\n", mi
.usmblks
);
30 printf("Free bytes held in fastbins (fsmblks): %d\n", mi
.fsmblks
);
31 printf("Total allocated space (uordblks): %d\n", mi
.uordblks
);
32 printf("Total free space (fordblks): %d\n", mi
.fordblks
);
33 printf("Topmost releasable block (keepcost): %d\n", mi
.keepcost
);
36 boost::mutex io_mutex
;
40 for (int i
= 0; i
< 10; ++i
) {
42 boost::mutex::scoped_lock
lock(io_mutex
);
44 //boost::this_thread::sleep( boost::posix_time::milliseconds( 100 ) );
51 for (int i
= 0; i
< 10; ++i
) {
53 boost::mutex::scoped_lock
lock(io_mutex
);
55 boost::this_thread::sleep( boost::posix_time::milliseconds( 100 ) );
62 printf("\n============== sizeof(boost::thread) ============== %d\n", sizeof(boost::thread
));
63 printf("\n============== sizeof(boost::detail::thread_data_base) ============== %d\n", sizeof(boost::detail::thread_data_base
));
64 printf("\n============== sizeof(boost::detail::thread_data<>) ============== %d\n", sizeof(boost::detail::thread_data
<void(*)()>));
65 printf("\n============== Before thread creation ==============\n");
68 boost::thread
thrd1(&count
);
70 printf("\n============== After thread creation ==============\n");
73 boost::thread
thrd2(&count
);
74 printf("\n============== After thread creation ==============\n");
76 boost::thread
thrd3(&count
);
77 printf("\n============== After thread creation ==============\n");
81 printf("\n============== After thread join ==============\n");
85 printf("\n============== After thread join ==============\n");
88 printf("\n============== After thread join ==============\n");
91 printf("\n============== After thread destruction ==============\n");
96 pthread_attr_init(&attr
);
99 pthread_create(&thrd1
, &attr
, &count2
, 0);
100 printf("\n============== After thread creation ==============\n");
104 pthread_create(&thrd2
, &attr
, &count2
, 0);
105 printf("\n============== After thread creation ==============\n");
109 pthread_create(&thrd3
, &attr
, &count2
, 0);
110 printf("\n============== After thread creation ==============\n");
113 pthread_attr_destroy(&attr
);
114 printf("\n============== After thread attr destroy ==============\n");
118 pthread_join(thrd3
, &res
);
119 printf("\n============== After thread join ==============\n");
122 pthread_join(thrd2
, &res
);
123 printf("\n============== After thread join ==============\n");
125 pthread_join(thrd1
, &res
);
126 printf("\n============== After thread join ==============\n");
131 //pthread_destroy(&thrd1);
132 //pthread_destroy(&thrd2);
133 //pthread_destroy(&thrd3);
135 printf("\n============== After thread destruction ==============\n");