| 1 | /* |
| 2 | Copyright (C) 2021-2024 Sutou Kouhei <[email protected]> |
| 3 | |
| 4 | This library is free software; you can redistribute it and/or |
| 5 | modify it under the terms of the GNU Lesser General Public |
| 6 | License as published by the Free Software Foundation; either |
| 7 | version 2.1 of the License, or (at your option) any later version. |
| 8 | |
| 9 | This library is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | Lesser General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU Lesser General Public |
| 15 | License along with this library; if not, write to the Free Software |
| 16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 | */ |
| 18 | |
| 19 | #pragma once |
| 20 | |
| 21 | #include "grn_ctx.h" |
| 22 | #include "grn_task_executor.hpp" |
| 23 | |
| 24 | GRN_API grn::TaskExecutor * |
| 25 | grn_ctx_get_task_executor(grn_ctx *ctx); |
| 26 | |
| 27 | namespace grn { |
| 28 | class ChildCtxReleaser { |
| 29 | public: |
| 30 | ChildCtxReleaser(grn_ctx *ctx, grn_ctx *child_ctx) |
| 31 | : ctx_(ctx), |
| 32 | child_ctx_(child_ctx) {}; |
| 33 | |
| 34 | ~ChildCtxReleaser() |
| 35 | { |
| 36 | if (child_ctx_) { |
| 37 | grn_ctx_release_child(ctx_, child_ctx_); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | private: |
| 42 | grn_ctx *ctx_; |
| 43 | grn_ctx *child_ctx_; |
| 44 | }; |
| 45 | } // namespace grn |