--- /dev/null
+#include <future>
+#include <iostream>
+#ifdef WIN32
+#include <windows.h>
+#else
+#endif
+
+class Test
+{
+private:
+ std::vector<int> state;
+ std::vector<int>::iterator it;
+ std::vector<bool> isAvailable;
+public:
+ Test()
+ {
+ this->it = this->state.begin();
+ }
+
+ void called_from_async()
+ {
+#ifdef WIN32
+ Sleep(2000);
+#else
+ usleep(2000 * 1000);
+#endif
+ std::cout << "called from async" << std::endl;
+ this->state.insert(this->it ,10);
+ }
+
+ std::string returned_from_async() {
+#ifdef WIN32
+ Sleep(2000);
+#else
+ usleep(2000 * 1000);
+#endif
+ //std::cout << "Async call" << std::endl;
+ return "Async call";
+ }
+
+ template<class ASYNC>
+ void print_results(ASYNC &f)
+ {
+ std::string result = f.get();
+ std::cout << result.c_str() << std::endl;
+ }
+
+ int getState(int pos)
+ {
+ return this->state.at(pos);
+ }
+
+ int getStateSize()
+ {
+ return this->state.size();
+ }
+};
+
+int main() {
+ Test test;
+ std::future<void> result(std::async(&Test::called_from_async, &test));
+
+ auto f1 = std::async(std::launch::async, &Test::returned_from_async, &test);
+
+ std::cout << "Message from main." << std::endl;
+ do
+ {
+ std::cout << test.getStateSize();
+ } while (test.getStateSize()<1);
+
+#ifdef _DEBUG
+ auto i = 0;
+ std::cout << "wait for close";
+ std::cin >> i;
+#endif
+
+ return 0;
+
+}
\ No newline at end of file
else
return( NULL );
*/
+ return 0;
}
// -------------------------------------------------------------------------
image->GetScalarRange( r );
return( r[ 1 ] - r[ 0 ] );
*/
+ return 0;
}
// -------------------------------------------------------------------------
image->GetScalarRange( r );
return( r[ 0 ] );
*/
+ return 0;
}
// -------------------------------------------------------------------------
image->GetScalarRange( r );
return( r[ 1 ] );
*/
+ return 0;
}
// -------------------------------------------------------------------------
else
return( double( 0 ) );
*/
+ return 0;
}
// -------------------------------------------------------------------------
else
return( double( 0 ) );
*/
+ return 0;
}
// -------------------------------------------------------------------------