| 2741 | |
| 2742 | #if NAPI_HAS_THREADS |
| 2743 | class AsyncWorker { |
| 2744 | public: |
| 2745 | virtual ~AsyncWorker(); |
| 2746 | |
| 2747 | NAPI_DISALLOW_ASSIGN_COPY(AsyncWorker) |
| 2748 | |
| 2749 | operator napi_async_work() const; |
| 2750 | |
| 2751 | Napi::Env Env() const; |
| 2752 | |
| 2753 | void Queue(); |
| 2754 | void Cancel(); |
| 2755 | void SuppressDestruct(); |
| 2756 | |
| 2757 | ObjectReference& Receiver(); |
| 2758 | FunctionReference& Callback(); |
| 2759 | |
| 2760 | virtual void OnExecute(Napi::Env env); |
| 2761 | virtual void OnWorkComplete(Napi::Env env, napi_status status); |
| 2762 | |
| 2763 | protected: |
| 2764 | explicit AsyncWorker(const Function& callback); |
| 2765 | explicit AsyncWorker(const Function& callback, const char* resource_name); |
| 2766 | explicit AsyncWorker(const Function& callback, |
| 2767 | const char* resource_name, |
| 2768 | const Object& resource); |
| 2769 | explicit AsyncWorker(const Object& receiver, const Function& callback); |
| 2770 | explicit AsyncWorker(const Object& receiver, |
| 2771 | const Function& callback, |
| 2772 | const char* resource_name); |
| 2773 | explicit AsyncWorker(const Object& receiver, |
| 2774 | const Function& callback, |
| 2775 | const char* resource_name, |
| 2776 | const Object& resource); |
| 2777 | |
| 2778 | explicit AsyncWorker(Napi::Env env); |
| 2779 | explicit AsyncWorker(Napi::Env env, const char* resource_name); |
| 2780 | explicit AsyncWorker(Napi::Env env, |
| 2781 | const char* resource_name, |
| 2782 | const Object& resource); |
| 2783 | |
| 2784 | virtual void Execute() = 0; |
| 2785 | virtual void OnOK(); |
| 2786 | virtual void OnError(const Error& e); |
| 2787 | virtual void Destroy(); |
| 2788 | virtual std::vector<napi_value> GetResult(Napi::Env env); |
| 2789 | |
| 2790 | void SetError(const std::string& error); |
| 2791 | |
| 2792 | private: |
| 2793 | static inline void OnAsyncWorkExecute(napi_env env, void* asyncworker); |
| 2794 | static inline void OnAsyncWorkComplete(napi_env env, |
| 2795 | napi_status status, |
| 2796 | void* asyncworker); |
| 2797 | |
| 2798 | napi_env _env; |
| 2799 | napi_async_work _work; |
| 2800 | ObjectReference _receiver; |
nothing calls this directly
no outgoing calls
no test coverage detected