Grid Community Toolkit  6.2.1653033972 (tag: v6.2.20220524)
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
globus_i_callback.h
1 /*
2  * Copyright 1999-2006 University of Chicago
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef GLOBUS_I_CALLBACK_H
18 #define GLOBUS_I_CALLBACK_H
19 
20 #include "globus_error.h"
21 #include "globus_error_generic.h"
22 
23 extern globus_module_descriptor_t globus_i_callback_module_nonthreaded;
24 extern globus_module_descriptor_t globus_i_callback_module_threaded;
25 
26 #define GLOBUS_CALLBACK_NONTHREADED_MODULE (&globus_i_callback_module_nonthreaded)
27 #define GLOBUS_CALLBACK_THREADED_MODULE (&globus_i_callback_module_threaded)
28 /* common error objects */
29 
30 #define GLOBUS_L_CALLBACK_CONSTRUCT_INVALID_CALLBACK_HANDLE(func) \
31  globus_error_put( \
32  globus_error_construct_error( \
33  GLOBUS_CALLBACK_MODULE, \
34  GLOBUS_NULL, \
35  GLOBUS_CALLBACK_ERROR_INVALID_CALLBACK_HANDLE, \
36  __FILE__, \
37  (func), \
38  __LINE__, \
39  "Invalid callback handle"))
40 
41 #define GLOBUS_L_CALLBACK_CONSTRUCT_INVALID_SPACE(func) \
42  globus_error_put( \
43  globus_error_construct_error( \
44  GLOBUS_CALLBACK_MODULE, \
45  GLOBUS_NULL, \
46  GLOBUS_CALLBACK_ERROR_INVALID_SPACE, \
47  __FILE__, \
48  (func), \
49  __LINE__, \
50  "Invalid space handle"))
51 
52 #define GLOBUS_L_CALLBACK_CONSTRUCT_MEMORY_ALLOC(func, alloc) \
53  globus_error_put( \
54  globus_error_construct_error( \
55  GLOBUS_CALLBACK_MODULE, \
56  GLOBUS_NULL, \
57  GLOBUS_CALLBACK_ERROR_MEMORY_ALLOC, \
58  __FILE__, \
59  (func), \
60  __LINE__, \
61  "Could not allocate memory for %s", \
62  (alloc)))
63 
64 #define GLOBUS_L_CALLBACK_CONSTRUCT_INVALID_ARGUMENT(func, argument) \
65  globus_error_put( \
66  globus_error_construct_error( \
67  GLOBUS_CALLBACK_MODULE, \
68  GLOBUS_NULL, \
69  GLOBUS_CALLBACK_ERROR_INVALID_ARGUMENT, \
70  __FILE__, \
71  (func), \
72  __LINE__, \
73  "Invalid argument: %s", \
74  (argument)))
75 
76 #define GLOBUS_L_CALLBACK_CONSTRUCT_ALREADY_CANCELED(func) \
77  globus_error_put( \
78  globus_error_construct_error( \
79  GLOBUS_CALLBACK_MODULE, \
80  GLOBUS_NULL, \
81  GLOBUS_CALLBACK_ERROR_ALREADY_CANCELED, \
82  __FILE__, \
83  (func), \
84  __LINE__, \
85  "Callback previoulsy unregistered"))
86 
87 #define GLOBUS_L_CALLBACK_CONSTRUCT_NO_ACTIVE_CALLBACK(func) \
88  globus_error_put( \
89  globus_error_construct_error( \
90  GLOBUS_CALLBACK_MODULE, \
91  GLOBUS_NULL, \
92  GLOBUS_CALLBACK_ERROR_NO_ACTIVE_CALLBACK, \
93  __FILE__, \
94  (func), \
95  __LINE__, \
96  "No cuurently running callback"))
97 
98 #define GlobusICallbackReadyInit(queue) \
99  do { \
100  (queue)->head = GLOBUS_NULL; \
101  (queue)->tail = &(queue)->head; \
102  } while(0)
103 
104 #define GlobusICallbackReadyEnqueue(queue, callback_info) \
105  do { \
106  (callback_info)->next = GLOBUS_NULL; \
107  *(queue)->tail = callback_info; \
108  (queue)->tail = &callback_info->next; \
109  } while(0)
110 
111 #define GlobusICallbackReadyEnqueueFirst(queue, callback_info) \
112  do { \
113  (callback_info)->next = (queue)->head; \
114  if(!(queue)->head) \
115  { \
116  (queue)->tail = &callback_info->next; \
117  } \
118  (queue)->head = (callback_info); \
119  } while(0)
120 
121 #define GlobusICallbackReadyDequeue(queue, callback_info) \
122  do { \
123  (callback_info) = (queue)->head; \
124  if((callback_info)) \
125  { \
126  (queue)->head = (callback_info)->next; \
127  if(!(queue)->head) \
128  { \
129  (queue)->tail = &(queue)->head; \
130  } \
131  } \
132  } while(0)
133 
134 #define GlobusICallbackReadyPeak(queue, callback_info) \
135  do { \
136  (callback_info) = (queue)->head; \
137  } while(0)
138 
139 #define GlobusICallbackReadyRemove(queue, callback_info) \
140  do { \
141  globus_l_callback_info_t ** tmp; \
142  \
143  tmp = &(queue)->head; \
144  while(*tmp && *tmp != (callback_info)) \
145  { \
146  tmp = &(*tmp)->next; \
147  } \
148  \
149  if(*tmp) \
150  { \
151  if(!(callback_info)->next) \
152  { \
153  (queue)->tail = tmp; \
154  } \
155  *tmp = (*tmp)->next; \
156  } \
157  } while(0)
158 
159 #endif /* GLOBUS_I_CALLBACK_H */
Globus Error Handling.
Globus Error API.
Module Descriptor.
Definition: globus_module.h:71