Microsoft Information Protection (MIP) SDK for C: Reference 1.15
Doxygen-generated documentation for MIP SDK written in C
Loading...
Searching...
No Matches
task_dispatcher_delegate_cc.h
Go to the documentation of this file.
1/*
2 *
3 * Copyright (c) Microsoft Corporation.
4 * All rights reserved.
5 *
6 * This code is licensed under the MIT License.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files(the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions :
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 *
26 */
27
28/**
29 * @brief Defines task dispatcher callback functions
30 *
31 * @file task_dispatcher_delegate_cc.h
32 */
33
34#ifndef API_MIP_TASK_DISPATCHER_DELEGATE_CC_H_
35#define API_MIP_TASK_DISPATCHER_DELEGATE_CC_H_
36
37#include <stddef.h>
38#include <stdint.h>
39
41#include "mip_cc/error_cc.h"
43#include "mip_cc/result_cc.h"
44
45/**
46 * @brief Defines a single async task dispatch request
47 */
48typedef struct {
49 const char* id; /**< Task ID */
50 int64_t delayMs; /**< Delay until task execution (in milliseconds) */
51 bool executeOnIndependentThread; /**< Whether this task should execute on a completely independent thread or can re-use a shared thread */
52 void* loggerContext; /**< logger context that should be used with the logger delegate before the task is run */
54
55/**
56 * @brief Callback function definition for dispatching an async task
57 *
58 * @param taskId Unique task identifier
59 */
60MIP_CC_CALLBACK(mip_cc_dispatch_task_callback_fn /*typename*/,
61 void /*return*/,
62 const mip_cc_async_task* /*task*/);
63
64/**
65 * @brief Callback function for canceling a background tasks
66 *
67 * @param taskId Unique task identifier
68 *
69 * @return True if task was successfully cancelled, else false
70 */
71MIP_CC_CALLBACK(mip_cc_cancel_task_callback_fn /*typename*/,
72 bool /*return*/,
73 const char* /*taskId*/);
74
75/**
76 * @brief Callback function for canceling all background tasks
77 */
78MIP_CC_CALLBACK(mip_cc_cancel_all_tasks_callback_fn /*typename*/,
79 void /*return*/);
80
82
83/**
84 * @brief Creates a task dispatcher delegate which can be used to override MIP's default async task handling
85 *
86 * @param dispatchTaskCallback Function pointer for dispatching async tasks
87 * @param cancelTaskCallback Function pointer for cancelling background tasks
88 * @param cancelAllTasksCallback Function pointer for cancelling all background tasks
89 * @param taskDispatcher [Output] Handle to task dispatcher delegate object
90 * @param errorInfo [Output] (Optional) Failure info if operation result is error
91 *
92 * @return Result code indicating success or failure
93 */
94MIP_CC_API(mip_cc_result) MIP_CC_CreateTaskDispatcherDelegate(
95 const mip_cc_dispatch_task_callback_fn dispatchTaskCallback,
96 const mip_cc_cancel_task_callback_fn cancelTaskCallback,
97 const mip_cc_cancel_all_tasks_callback_fn cancelAllTasksCallback,
100
101/**
102 * @brief Notifies a TaskDispatcher delegate that a task is scheduled to execute now on the current thread
103 *
104 * @param taskDispatcher Handle to task dispatcher delegate object
105 * @param taskId ID of async task associated with this operation
106 *
107 * @note This function must be called by the application when a task is scheduled to execute. It will result in
108 * immediate execution of the task on the current thread. The ID should match that of a previously-dispatched,
109 * non-cancelled task.
110 */
111MIP_CC_API(void) MIP_CC_ExecuteDispatchedTask(const mip_cc_task_dispatcher_delegate taskDispatcher, const char* taskId);
112
113/**
114 * @brief Release resources associated with an task dispatcher delegate handle
115 *
116 * @param taskDispatcher Task dispatcher delegate to be released
117 */
118MIP_CC_API(void) MIP_CC_ReleaseTaskDispatcherDelegate(mip_cc_task_dispatcher_delegate taskDispatcher);
119
120#endif // API_MIP_TASK_DISPATCHER_DELEGATE_CC_H_
A file Containing the common types used by the upe, file and protection modules.
Error definition and functions.
Export/import and other macros for C API.
Defines success/error result codes.
mip_cc_result
API success/failure result.
Definition result_cc.h:44
Defines a single async task dispatch request.
void * loggerContext
logger context that should be used with the logger delegate before the task is run
bool executeOnIndependentThread
Whether this task should execute on a completely independent thread or can re-use a shared thread.
int64_t delayMs
Delay until task execution (in milliseconds)
Error information.
Definition error_cc.h:79
Opaque handle to MIP object.
mip_cc_handle * mip_cc_task_dispatcher_delegate
const mip_cc_cancel_task_callback_fn const mip_cc_cancel_all_tasks_callback_fn mip_cc_task_dispatcher_delegate mip_cc_error * errorInfo
const mip_cc_cancel_task_callback_fn const mip_cc_cancel_all_tasks_callback_fn mip_cc_task_dispatcher_delegate * taskDispatcher
const char * taskId
MIP_CC_CALLBACK(mip_cc_dispatch_task_callback_fn, void, const mip_cc_async_task *)
Callback function definition for dispatching an async task.
const mip_cc_cancel_task_callback_fn cancelTaskCallback
MIP_CC_API(void) MIP_CC_ExecuteDispatchedTask(const mip_cc_task_dispatcher_delegate taskDispatcher
Notifies a TaskDispatcher delegate that a task is scheduled to execute now on the current thread.
const mip_cc_cancel_task_callback_fn const mip_cc_cancel_all_tasks_callback_fn cancelAllTasksCallback