| 1875 | |
| 1876 | #if (NAPI_VERSION > 3) |
| 1877 | class ThreadSafeFunction { |
| 1878 | public: |
| 1879 | // This API may only be called from the main thread. |
| 1880 | template <typename ResourceString> |
| 1881 | static ThreadSafeFunction New(napi_env env, |
| 1882 | const Function& callback, |
| 1883 | ResourceString resourceName, |
| 1884 | size_t maxQueueSize, |
| 1885 | size_t initialThreadCount); |
| 1886 | |
| 1887 | // This API may only be called from the main thread. |
| 1888 | template <typename ResourceString, typename ContextType> |
| 1889 | static ThreadSafeFunction New(napi_env env, |
| 1890 | const Function& callback, |
| 1891 | ResourceString resourceName, |
| 1892 | size_t maxQueueSize, |
| 1893 | size_t initialThreadCount, |
| 1894 | ContextType* context); |
| 1895 | |
| 1896 | // This API may only be called from the main thread. |
| 1897 | template <typename ResourceString, typename Finalizer> |
| 1898 | static ThreadSafeFunction New(napi_env env, |
| 1899 | const Function& callback, |
| 1900 | ResourceString resourceName, |
| 1901 | size_t maxQueueSize, |
| 1902 | size_t initialThreadCount, |
| 1903 | Finalizer finalizeCallback); |
| 1904 | |
| 1905 | // This API may only be called from the main thread. |
| 1906 | template <typename ResourceString, typename Finalizer, |
| 1907 | typename FinalizerDataType> |
| 1908 | static ThreadSafeFunction New(napi_env env, |
| 1909 | const Function& callback, |
| 1910 | ResourceString resourceName, |
| 1911 | size_t maxQueueSize, |
| 1912 | size_t initialThreadCount, |
| 1913 | Finalizer finalizeCallback, |
| 1914 | FinalizerDataType* data); |
| 1915 | |
| 1916 | // This API may only be called from the main thread. |
| 1917 | template <typename ResourceString, typename ContextType, typename Finalizer> |
| 1918 | static ThreadSafeFunction New(napi_env env, |
| 1919 | const Function& callback, |
| 1920 | ResourceString resourceName, |
| 1921 | size_t maxQueueSize, |
| 1922 | size_t initialThreadCount, |
| 1923 | ContextType* context, |
| 1924 | Finalizer finalizeCallback); |
| 1925 | |
| 1926 | // This API may only be called from the main thread. |
| 1927 | template <typename ResourceString, typename ContextType, |
| 1928 | typename Finalizer, typename FinalizerDataType> |
| 1929 | static ThreadSafeFunction New(napi_env env, |
| 1930 | const Function& callback, |
| 1931 | ResourceString resourceName, |
| 1932 | size_t maxQueueSize, |
| 1933 | size_t initialThreadCount, |
| 1934 | ContextType* context, |