| 37 | } |
| 38 | |
| 39 | std::shared_ptr<HandlerThread> HandlerThread::Make() { |
| 40 | JNIEnvironment environment; |
| 41 | auto env = environment.current(); |
| 42 | if (env == nullptr) { |
| 43 | return nullptr; |
| 44 | } |
| 45 | auto name = env->NewStringUTF("tgfx_HandlerThread"); |
| 46 | auto thread = env->NewObject(HandlerThreadClass.get(), HandlerThread_Constructor, name); |
| 47 | env->CallVoidMethod(thread, HandlerThread_start); |
| 48 | if (env->ExceptionCheck()) { |
| 49 | env->ExceptionClear(); |
| 50 | LOGE("HandlerThread::Make(): failed to start the HandlerThread!"); |
| 51 | return nullptr; |
| 52 | } |
| 53 | return std::make_shared<HandlerThread>(env, thread); |
| 54 | } |
| 55 | |
| 56 | HandlerThread::HandlerThread(JNIEnv* env, jobject handlerThread) { |
| 57 | thread = handlerThread; |