abstract */
| 2167 | template<class T> |
| 2168 | /* abstract */ |
| 2169 | class AsyncBareProgressWorker : public AsyncBareProgressWorkerBase { |
| 2170 | public: |
| 2171 | explicit AsyncBareProgressWorker( |
| 2172 | Callback *callback_, |
| 2173 | const char* resource_name = "nan:AsyncBareProgressWorker") |
| 2174 | : AsyncBareProgressWorkerBase(callback_, resource_name) { |
| 2175 | uv_mutex_init(&async_lock); |
| 2176 | } |
| 2177 | |
| 2178 | virtual ~AsyncBareProgressWorker() { |
| 2179 | uv_mutex_destroy(&async_lock); |
| 2180 | } |
| 2181 | |
| 2182 | class ExecutionProgress { |
| 2183 | friend class AsyncBareProgressWorker; |
| 2184 | public: |
| 2185 | void Signal() const { |
| 2186 | uv_mutex_lock(&that_->async_lock); |
| 2187 | uv_async_send(&that_->async); |
| 2188 | uv_mutex_unlock(&that_->async_lock); |
| 2189 | } |
| 2190 | |
| 2191 | void Send(const T* data, size_t count) const { |
| 2192 | that_->SendProgress_(data, count); |
| 2193 | } |
| 2194 | |
| 2195 | private: |
| 2196 | explicit ExecutionProgress(AsyncBareProgressWorker *that) : that_(that) {} |
| 2197 | NAN_DISALLOW_ASSIGN_COPY_MOVE(ExecutionProgress) |
| 2198 | AsyncBareProgressWorker* const that_; |
| 2199 | }; |
| 2200 | |
| 2201 | virtual void Execute(const ExecutionProgress& progress) = 0; |
| 2202 | virtual void HandleProgressCallback(const T *data, size_t size) = 0; |
| 2203 | |
| 2204 | protected: |
| 2205 | uv_mutex_t async_lock; |
| 2206 | |
| 2207 | private: |
| 2208 | void Execute() /*final override*/ { |
| 2209 | ExecutionProgress progress(this); |
| 2210 | Execute(progress); |
| 2211 | } |
| 2212 | |
| 2213 | virtual void SendProgress_(const T *data, size_t count) = 0; |
| 2214 | }; |
| 2215 | |
| 2216 | template<class T> |
| 2217 | /* abstract */ |
nothing calls this directly
no outgoing calls
no test coverage detected