To continue improving the user experience, we should make long-running tasks asynchronous, with fine-grained control over their execution. To do so, we implement an abstraction layer on top of the operating systems' threads.
Android NDK threads are based on POSIX threads. Take a look at the header file platforms\android-14\arch-arm\usr\include\pthread.h
in your NDK folder.
Let's start with declarations of thread handle types:
#ifndef _WIN32 #include <pthread.h> typedef pthread_t thread_handle_t; typedef pthread_t native_thread_handle_t; #else #include <windows.h> typedef uintptr_t thread_handle_t; typedef uintptr_t native_thread_handle_t; #endif
Then, we declare the thread interface:
class iThread { public: iThread::iThread():FThreadHandle( 0 ), FPendingExit(false) {} virtual ~iThread() {} void Start(); void Exit( bool Wait ); bool IsPendingExit() const { return FPendingExit; }; protected: virtual void...