/* * soft_handler.h - soft image handler class * * Copyright (c) 2017 Intel Corporation * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * Author: Wind Yuan */ #ifndef XCAM_SOFT_HANDLER_H #define XCAM_SOFT_HANDLER_H #include #include #include #include namespace XCam { class SoftHandler; class ThreadPool; class SyncMeta; class SoftWorker; struct SoftArgs : Worker::Arguments { private: SmartPtr _param; public: explicit SoftArgs (const SmartPtr ¶m = NULL) : _param (param) {} inline const SmartPtr &get_param () const { return _param; } inline void set_param (const SmartPtr ¶m) { _param = param; XCAM_ASSERT (param.ptr ()); } }; class SoftHandler : public ImageHandler { public: explicit SoftHandler (const char* name); ~SoftHandler (); bool set_threads (const SmartPtr &pool); // derive from ImageHandler virtual XCamReturn execute_buffer (const SmartPtr ¶m, bool sync); virtual XCamReturn finish (); virtual XCamReturn terminate (); protected: // derived from ImageHandler virtual SmartPtr create_allocator (); virtual XCamReturn configure_rest (); //virtual SmartPtr get_first_worker_args (const SmartPtr &worker, SmartPtr ¶ms) = 0; virtual void work_well_done (const SmartPtr ¶m, XCamReturn err); virtual void work_broken (const SmartPtr ¶m, XCamReturn err); //directly usage bool check_work_continue (const SmartPtr ¶m, XCamReturn err); private: void param_ended (SmartPtr param, XCamReturn err); static bool is_param_error (const SmartPtr ¶m); private: XCAM_DEAD_COPY (SoftHandler); private: SmartPtr _threads; SmartPtr _cur_sync; SafeList _params; mutable std::atomic _wip_buf_count; }; } #endif //XCAM_SOFT_HANDLER_H