Index: /experimental/Threading/Threading.sln
===================================================================
--- /experimental/Threading/Threading.sln (revision 427)
+++ /experimental/Threading/Threading.sln (revision 428)
@@ -3,4 +3,6 @@
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Threading", "Threading\Threading.vcproj", "{0DA5F800-C727-4724-8FEE-4787703ED9B6}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Timer", "Timer\Timer.vcproj", "{30B593AA-3661-4498-BAF1-15D701886EB2}"
EndProject
Global
@@ -14,4 +16,8 @@
{0DA5F800-C727-4724-8FEE-4787703ED9B6}.Release|Win32.ActiveCfg = Release|Win32
{0DA5F800-C727-4724-8FEE-4787703ED9B6}.Release|Win32.Build.0 = Release|Win32
+ {30B593AA-3661-4498-BAF1-15D701886EB2}.Debug|Win32.ActiveCfg = Debug|Win32
+ {30B593AA-3661-4498-BAF1-15D701886EB2}.Debug|Win32.Build.0 = Debug|Win32
+ {30B593AA-3661-4498-BAF1-15D701886EB2}.Release|Win32.ActiveCfg = Release|Win32
+ {30B593AA-3661-4498-BAF1-15D701886EB2}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
Index: /experimental/Threading/Timer/Timer.vcproj
===================================================================
--- /experimental/Threading/Timer/Timer.vcproj (revision 428)
+++ /experimental/Threading/Timer/Timer.vcproj (revision 428)
@@ -0,0 +1,200 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: /experimental/Threading/Timer/main.cpp
===================================================================
--- /experimental/Threading/Timer/main.cpp (revision 428)
+++ /experimental/Threading/Timer/main.cpp (revision 428)
@@ -0,0 +1,74 @@
+// Timer Test
+
+#define _WIN32_WINNT 0x0601
+
+// OSG includes
+#include
+#include
+#include
+#include
+
+
+
+using namespace std;
+
+class timed_class
+{
+public:
+ timed_class(boost::asio::io_service& io_service) : _timer(io_service), i(0), timer(*osg::Timer::instance())
+ {
+ last_tick = timer.tick();
+
+ // now schedule the first timer.
+
+ _timer.expires_from_now(boost::posix_time::milliseconds(1000/60)); // runs with 60Hz
+ _timer.async_wait(boost::bind(&timed_class::handle_timeout, this, boost::asio::placeholders::error));
+ }
+
+ void handle_timeout(boost::system::error_code const& cError)
+ {
+ if (cError.value() == boost::asio::error::operation_aborted)
+ return;
+
+ if (cError && cError.value() != boost::asio::error::operation_aborted)
+ return; // throw an exception?
+
+ // Schedule the timer again...
+ _timer.expires_from_now(boost::posix_time::milliseconds(1000/60)); // runs with 60Hz
+ _timer.async_wait(boost::bind(&timed_class::handle_timeout, this, boost::asio::placeholders::error));
+
+
+ // Payload
+ osg::Timer_t currentTick = timer.tick();
+ cout << timer.delta_m(last_tick,currentTick) << " msec" << endl;
+ last_tick = timer.tick();
+ }
+
+private:
+ boost::asio::deadline_timer _timer;
+ high_resolution_timer
+ int i;
+ const osg::Timer& timer;
+ osg::Timer_t last_tick;
+};
+
+
+
+int main( int argc, char **argv )
+{
+ boost::asio::io_service io_service;
+
+ timed_class t(io_service);
+
+ //io_service.run(); // Start ioService in this thread( blocking
+
+ // Start Timer in another thread to continue this thread
+ boost::thread thread(boost::bind(&boost::asio::io_service::run, &io_service));
+
+ // OUtput stuff to show th thread is working
+ while(1)
+ //OSG_ALWAYS<<"Main Thread:"<