2 #include "OSGBaseInitFunctions.h"
5 #ifdef OSG_USE_PTHREADS
10 void *runThread(void *)
12 fprintf(stderr
, "run thread \n");
14 fprintf(stderr
, "th : %p %p %d 0x%016" PRIx64
" 0x%016" PRIx64
"\n",
15 static_cast<void *>(OSG::Thread::getCurrentChangeList ()),
16 static_cast<void *>(OSG::Thread::getCurrent ()),
17 OSG::Thread::getCurrentAspect (),
18 OSG::Thread::getCurrentNamespaceMask(),
19 OSG::Thread::getCurrentLocalFlags ());
21 fprintf(stderr
, "th : %p %p %d 0x%016" PRIx64
" 0x%016" PRIx64
"\n",
22 static_cast<void *>(OSG::Thread::getCurrentChangeList ()),
23 static_cast<void *>(OSG::Thread::getCurrent ()),
24 OSG::Thread::getCurrentAspect (),
25 OSG::Thread::getCurrentNamespaceMask(),
26 OSG::Thread::getCurrentLocalFlags ());
28 OSG::NodeUnrecPtr pNode1
= OSG::Node::create();
30 OSG::NodeUnrecPtr pNode2
= OSG::Node::create();
31 OSG::NodeUnrecPtr pNode3
= OSG::Node::create();
33 pNode1
->addChild(pNode2
);
34 pNode1
->addChild(pNode3
);
36 fprintf(stderr
, "exit thread\n");
41 void runThread1(void *)
43 fprintf(stderr
, "run thread \n");
45 fprintf(stderr
, "th : %p %p %d 0x%016" PRIx64
" 0x%016" PRIx64
"\n",
46 static_cast<void *>(OSG::Thread::getCurrentChangeList ()),
47 static_cast<void *>(OSG::Thread::getCurrent ()),
48 OSG::Thread::getCurrentAspect (),
49 OSG::Thread::getCurrentNamespaceMask(),
50 OSG::Thread::getCurrentLocalFlags ());
52 fprintf(stderr
, "th : %p %p %d 0x%016" PRIx64
" 0x%016" PRIx64
"\n",
53 static_cast<void *>(OSG::Thread::getCurrentChangeList ()),
54 static_cast<void *>(OSG::Thread::getCurrent ()),
55 OSG::Thread::getCurrentAspect (),
56 OSG::Thread::getCurrentNamespaceMask(),
57 OSG::Thread::getCurrentLocalFlags ());
59 OSG::NodeUnrecPtr pNode1
= OSG::Node::create();
61 OSG::NodeUnrecPtr pNode2
= OSG::Node::create();
62 OSG::NodeUnrecPtr pNode3
= OSG::Node::create();
64 pNode1
->addChild(pNode2
);
65 pNode1
->addChild(pNode3
);
67 fprintf(stderr
, "exit thread\n");
70 int main (int argc
, char **argv
)
72 OSG::osgInit(argc
, argv
);
74 #ifdef OSG_ENABLE_AUTOINIT_THREADS
75 OSG::Thread::setFallbackAspectId(42);
78 #ifdef OSG_ENABLE_AUTOINIT_THREADS
79 pthread_create(&oThread
, NULL
, runThread
, NULL
);
81 pthread_join(oThread
, NULL
);
85 OSG::ThreadRefPtr pThread
= OSG::Thread::get(NULL
, false);
87 pThread
->runFunction(runThread1
, 0, NULL
);
89 OSG::Thread::join(pThread
);
100 #ifdef OSG_USE_WINTHREADS
104 void *runThread(void *)
106 fprintf(stderr
, "run thread \n");
109 fprintf(stderr
, "%d ",
110 OSG::Thread::getCurrentAspect ());
112 fprintf(stderr
, "th : T:%p ",
113 static_cast<void *>(OSG::Thread::getCurrent ()));
114 fprintf(stderr
, "CL:%p ",
115 static_cast<void *>(OSG::Thread::getCurrentChangeList ()));
117 fprintf(stderr
, "0x%016" PRIx64
" ",
118 OSG::Thread::getCurrentNamespaceMask());
120 fprintf(stderr
, "0x%016" PRIx64
"\n",
121 OSG::Thread::getCurrentLocalFlags ());
123 OSG::NodeUnrecPtr pNode1
= OSG::Node::create();
125 OSG::NodeUnrecPtr pNode2
= OSG::Node::create();
126 OSG::NodeUnrecPtr pNode3
= OSG::Node::create();
128 pNode1
->addChild(pNode2
);
129 pNode1
->addChild(pNode3
);
132 fprintf(stderr
, "exit thread\n");
137 void runThread1(void *)
139 fprintf(stderr
, "run thread \n");
141 fprintf(stderr
, "th : CL:%p T:%p %d 0x%016" PRIx64
" 0x%016" PRIx64
"\n",
142 static_cast<void *>(OSG::Thread::getCurrentChangeList ()),
143 static_cast<void *>(OSG::Thread::getCurrent ()),
144 OSG::Thread::getCurrentAspect (),
145 OSG::Thread::getCurrentNamespaceMask(),
146 OSG::Thread::getCurrentLocalFlags ());
148 fprintf(stderr
, "th : CL:%p T:%p %d 0x%016" PRIx64
" 0x%016" PRIx64
"\n",
149 static_cast<void *>(OSG::Thread::getCurrentChangeList ()),
150 static_cast<void *>(OSG::Thread::getCurrent ()),
151 OSG::Thread::getCurrentAspect (),
152 OSG::Thread::getCurrentNamespaceMask(),
153 OSG::Thread::getCurrentLocalFlags ());
155 OSG::NodeUnrecPtr pNode1
= OSG::Node::create();
157 OSG::NodeUnrecPtr pNode2
= OSG::Node::create();
158 OSG::NodeUnrecPtr pNode3
= OSG::Node::create();
160 pNode1
->addChild(pNode2
);
161 pNode1
->addChild(pNode3
);
163 fprintf(stderr
, "exit thread\n");
166 int main (int argc
, char **argv
)
168 OSG::osgInit(argc
, argv
);
170 #ifdef OSG_ENABLE_AUTOINIT_THREADS
171 OSG::Thread::setFallbackAspectId(42);
174 #ifdef OSG_ENABLE_AUTOINIT_THREADS
177 OSG::Handle rc
= CreateThread(NULL
,
179 (LPTHREAD_START_ROUTINE
) runThread
,
184 WaitForSingleObject(rc
, INFINITE
);
188 OSG::ThreadRefPtr pThread
= OSG::Thread::get(NULL
, false);
190 pThread
->runFunction(runThread1
, 0, NULL
);
192 OSG::Thread::join(pThread
);