Ticket #7965: main.cpp

File main.cpp, 915 bytes (added by Gregor Jasny <gjasny@…>, 10 years ago)
Line 
1#include <cstring>
2#include <iostream>
3
4struct LargeObject
5{
6 LargeObject() { std::memset(blob, 0, sizeof(blob)); }
7 unsigned char blob[10*1024*1024];
8};
9
10#if __cplusplus > 199711L
11
12#include <memory>
13
14using std::make_shared;
15typedef std::shared_ptr<LargeObject> LargeObjectPtr;
16
17#else
18
19#include <boost/shared_ptr.hpp>
20#include <boost/make_shared.hpp>
21
22using boost::make_shared;
23typedef ::boost::shared_ptr<LargeObject> LargeObjectPtr;
24
25#endif
26
27static void* worker(void* arg)
28{
29 //LargeObject foo;
30 LargeObjectPtr ptr = make_shared<LargeObject>();
31 // LargeObjectPtr ptr(new LargeObject);
32
33 return 0;
34}
35
36int main(int argc, const char * argv[])
37{
38 pthread_attr_t attribute;
39
40 pthread_attr_init(&attribute);
41 pthread_attr_setstacksize(&attribute, 4096*10);
42
43 pthread_t thread;
44 pthread_create(&thread, &attribute, worker, 0);
45
46 pthread_join(thread, 0);
47
48 return 0;
49}