Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:38:43

0001 /*
0002  * Copyright (c) CERN 2013-2017
0003  *
0004  * Copyright (c) Members of the EMI Collaboration. 2010-2013
0005  *  See  http://www.eu-emi.eu/partners for details on the copyright
0006  *  holders.
0007  *
0008  * Licensed under the Apache License, Version 2.0 (the "License");
0009  * you may not use this file except in compliance with the License.
0010  * You may obtain a copy of the License at
0011  *
0012  *    http://www.apache.org/licenses/LICENSE-2.0
0013  *
0014  * Unless required by applicable law or agreed to in writing, software
0015  * distributed under the License is distributed on an "AS IS" BASIS,
0016  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0017  * See the License for the specific language governing permissions and
0018  * limitations under the License.
0019  */
0020 
0021 #pragma once
0022 #ifndef GFAL_CANCEL_H_
0023 #define GFAL_CANCEL_H_
0024 
0025 #if !defined(__GFAL2_H_INSIDE__) && !defined(__GFAL2_BUILD__)
0026 #   warning "Direct inclusion of gfal2 headers is deprecated. Please, include only gfal_api.h or gfal_plugins_api.h"
0027 #endif
0028 
0029 #include "gfal_common.h"
0030 #include "gfal_constants.h"
0031 
0032 
0033 #ifdef __cplusplus
0034 extern "C"
0035 {
0036 #endif
0037 
0038 typedef struct gfal_cancel_token_s* gfal_cancel_token_t;
0039 typedef void (*gfal_cancel_hook_cb)(gfal2_context_t context, void* userdata);
0040 
0041 /**
0042  * @brief cancel operation
0043  *
0044  * cancel all pending operation on the given context
0045  * blocking until all operations finish
0046  * all operations will return and trigger an ECANCELED if interrupted.
0047  * Thread safe
0048  * @param context : gfal 2 context
0049  * @return number of operations canceled
0050  */
0051 int gfal2_cancel(gfal2_context_t context);
0052 
0053 /**
0054  * @brief cancel status
0055  * @return true if \ref gfal2_cancel has been called
0056  *
0057  * @param context
0058  * @return true if success
0059  */
0060 gboolean gfal2_is_canceled(gfal2_context_t context);
0061 
0062 /**
0063  * Register a cancel hook, called in each cancellation
0064  * Thread-safe
0065  */
0066 gfal_cancel_token_t gfal2_register_cancel_callback(gfal2_context_t context,
0067         gfal_cancel_hook_cb cb, void* userdata);
0068 
0069 /**
0070  * Remove a cancel hook
0071  * Thread-safe
0072  */
0073 void gfal2_remove_cancel_callback(gfal2_context_t context, gfal_cancel_token_t token);
0074 
0075 /**
0076  * Mark the beginning of a cancellable scope
0077  */
0078 int gfal2_start_scope_cancel(gfal2_context_t context, GError** err);
0079 
0080 /**
0081  * Mark the end of a cancellable scope
0082  */
0083 int gfal2_end_scope_cancel(gfal2_context_t context);
0084 
0085 /**
0086  * GQuark of a cancel action
0087  */
0088 GQuark gfal_cancel_quark();
0089 
0090 /** Convenience macro for gfal2_start_scope_cancel */
0091 #define GFAL2_BEGIN_SCOPE_CANCEL(context, ret_err_value, err) \
0092     do{                                                       \
0093     if(gfal2_start_scope_cancel(context, err) < 0){           \
0094         return ret_err_value;                                 \
0095     }                                                         \
0096     }while(0)
0097 
0098 /** Convenience macro for gfal2_end_scope_cancel */
0099 #define GFAL2_END_SCOPE_CANCEL(context) \
0100     gfal2_end_scope_cancel(context)
0101 
0102 #ifdef __cplusplus
0103 }
0104 #endif
0105 
0106 
0107 #endif /* GFAL_CANCEL_H_ */