| 2806 | |
| 2807 | #if (NAPI_VERSION > 3 && NAPI_HAS_THREADS) |
| 2808 | class ThreadSafeFunction { |
| 2809 | public: |
| 2810 | // This API may only be called from the main thread. |
| 2811 | template <typename ResourceString> |
| 2812 | static ThreadSafeFunction New(napi_env env, |
| 2813 | const Function& callback, |
| 2814 | ResourceString resourceName, |
| 2815 | size_t maxQueueSize, |
| 2816 | size_t initialThreadCount); |
| 2817 | |
| 2818 | // This API may only be called from the main thread. |
| 2819 | template <typename ResourceString, typename ContextType> |
| 2820 | static ThreadSafeFunction New(napi_env env, |
| 2821 | const Function& callback, |
| 2822 | ResourceString resourceName, |
| 2823 | size_t maxQueueSize, |
| 2824 | size_t initialThreadCount, |
| 2825 | ContextType* context); |
| 2826 | |
| 2827 | // This API may only be called from the main thread. |
| 2828 | template <typename ResourceString, typename Finalizer> |
| 2829 | static ThreadSafeFunction New(napi_env env, |
| 2830 | const Function& callback, |
| 2831 | ResourceString resourceName, |
| 2832 | size_t maxQueueSize, |
| 2833 | size_t initialThreadCount, |
| 2834 | Finalizer finalizeCallback); |
| 2835 | |
| 2836 | // This API may only be called from the main thread. |
| 2837 | template <typename ResourceString, |
| 2838 | typename Finalizer, |
| 2839 | typename FinalizerDataType> |
| 2840 | static ThreadSafeFunction New(napi_env env, |
| 2841 | const Function& callback, |
| 2842 | ResourceString resourceName, |
| 2843 | size_t maxQueueSize, |
| 2844 | size_t initialThreadCount, |
| 2845 | Finalizer finalizeCallback, |
| 2846 | FinalizerDataType* data); |
| 2847 | |
| 2848 | // This API may only be called from the main thread. |
| 2849 | template <typename ResourceString, typename ContextType, typename Finalizer> |
| 2850 | static ThreadSafeFunction New(napi_env env, |
| 2851 | const Function& callback, |
| 2852 | ResourceString resourceName, |
| 2853 | size_t maxQueueSize, |
| 2854 | size_t initialThreadCount, |
| 2855 | ContextType* context, |
| 2856 | Finalizer finalizeCallback); |
| 2857 | |
| 2858 | // This API may only be called from the main thread. |
| 2859 | template <typename ResourceString, |
| 2860 | typename ContextType, |
| 2861 | typename Finalizer, |
| 2862 | typename FinalizerDataType> |
| 2863 | static ThreadSafeFunction New(napi_env env, |
| 2864 | const Function& callback, |
| 2865 | ResourceString resourceName, |
no outgoing calls