File: future-functions.c

package info (click to toggle)
syslog-ng 3.8.1-10
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 47,320 kB
  • ctags: 43,937
  • sloc: ansic: 159,432; yacc: 25,059; sh: 13,574; makefile: 4,669; python: 3,468; java: 3,218; xml: 2,309; perl: 318; lex: 316; awk: 184
file content (472 lines) | stat: -rw-r--r-- 13,210 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
/**************************************************
 *
 * Generated by build/generate-future-functions.py.
 *
 * DO NOT EDIT THIS FILE.
 *
 *************************************************/

/*
 * Define two sets of functions: background functions and future functions.

 * A background function like background_mongoc_cursor_next runs a driver
 * operation on a thread.

 * A future function like future_mongoc_cursor_next launches the background
 * operation and returns a future_t that will resolve when the operation
 * finishes.
 *
 * These are used with mock_server_t so you can run the driver on a thread while
 * controlling the server from the main thread.
 */

#include "mongoc-topology-private.h"

#include "future-functions.h"


static void *
background_mongoc_bulk_operation_execute (void *data)
{
   future_t *future = (future_t *) data;
   future_value_t return_value;

   return_value.type = future_value_uint32_t_type;

   future_value_set_uint32_t (
      &return_value,
      mongoc_bulk_operation_execute (
         future_value_get_mongoc_bulk_operation_ptr (future_get_param (future, 0)),
         future_value_get_bson_ptr (future_get_param (future, 1)),
         future_value_get_bson_error_ptr (future_get_param (future, 2))
      ));

   future_resolve (future, return_value);

   return NULL;
}

static void *
background_mongoc_client_command_simple (void *data)
{
   future_t *future = (future_t *) data;
   future_value_t return_value;

   return_value.type = future_value_bool_type;

   future_value_set_bool (
      &return_value,
      mongoc_client_command_simple (
         future_value_get_mongoc_client_ptr (future_get_param (future, 0)),
         future_value_get_const_char_ptr (future_get_param (future, 1)),
         future_value_get_const_bson_ptr (future_get_param (future, 2)),
         future_value_get_const_mongoc_read_prefs_ptr (future_get_param (future, 3)),
         future_value_get_bson_ptr (future_get_param (future, 4)),
         future_value_get_bson_error_ptr (future_get_param (future, 5))
      ));

   future_resolve (future, return_value);

   return NULL;
}

static void *
background_mongoc_client_kill_cursor (void *data)
{
   future_t *future = (future_t *) data;
   future_value_t return_value;

   return_value.type = future_value_void_type;

   mongoc_client_kill_cursor (
      future_value_get_mongoc_client_ptr (future_get_param (future, 0)),
      future_value_get_int64_t (future_get_param (future, 1)));

   future_resolve (future, return_value);

   return NULL;
}

static void *
background_mongoc_collection_aggregate (void *data)
{
   future_t *future = (future_t *) data;
   future_value_t return_value;

   return_value.type = future_value_mongoc_cursor_ptr_type;

   future_value_set_mongoc_cursor_ptr (
      &return_value,
      mongoc_collection_aggregate (
         future_value_get_mongoc_collection_ptr (future_get_param (future, 0)),
         future_value_get_mongoc_query_flags_t (future_get_param (future, 1)),
         future_value_get_const_bson_ptr (future_get_param (future, 2)),
         future_value_get_const_bson_ptr (future_get_param (future, 3)),
         future_value_get_const_mongoc_read_prefs_ptr (future_get_param (future, 4))
      ));

   future_resolve (future, return_value);

   return NULL;
}

static void *
background_mongoc_collection_insert_bulk (void *data)
{
   future_t *future = (future_t *) data;
   future_value_t return_value;

   return_value.type = future_value_bool_type;

   future_value_set_bool (
      &return_value,
      mongoc_collection_insert_bulk (
         future_value_get_mongoc_collection_ptr (future_get_param (future, 0)),
         future_value_get_mongoc_insert_flags_t (future_get_param (future, 1)),
         future_value_get_const_bson_ptr_ptr (future_get_param (future, 2)),
         future_value_get_uint32_t (future_get_param (future, 3)),
         future_value_get_const_mongoc_write_concern_ptr (future_get_param (future, 4)),
         future_value_get_bson_error_ptr (future_get_param (future, 5))
      ));

   future_resolve (future, return_value);

   return NULL;
}

static void *
background_mongoc_cursor_destroy (void *data)
{
   future_t *future = (future_t *) data;
   future_value_t return_value;

   return_value.type = future_value_void_type;

   mongoc_cursor_destroy (
      future_value_get_mongoc_cursor_ptr (future_get_param (future, 0)));

   future_resolve (future, return_value);

   return NULL;
}

static void *
background_mongoc_cursor_next (void *data)
{
   future_t *future = (future_t *) data;
   future_value_t return_value;

   return_value.type = future_value_bool_type;

   future_value_set_bool (
      &return_value,
      mongoc_cursor_next (
         future_value_get_mongoc_cursor_ptr (future_get_param (future, 0)),
         future_value_get_const_bson_ptr_ptr (future_get_param (future, 1))
      ));

   future_resolve (future, return_value);

   return NULL;
}

static void *
background_mongoc_client_get_database_names (void *data)
{
   future_t *future = (future_t *) data;
   future_value_t return_value;

   return_value.type = future_value_char_ptr_ptr_type;

   future_value_set_char_ptr_ptr (
      &return_value,
      mongoc_client_get_database_names (
         future_value_get_mongoc_client_ptr (future_get_param (future, 0)),
         future_value_get_bson_error_ptr (future_get_param (future, 1))
      ));

   future_resolve (future, return_value);

   return NULL;
}

static void *
background_mongoc_database_get_collection_names (void *data)
{
   future_t *future = (future_t *) data;
   future_value_t return_value;

   return_value.type = future_value_char_ptr_ptr_type;

   future_value_set_char_ptr_ptr (
      &return_value,
      mongoc_database_get_collection_names (
         future_value_get_mongoc_database_ptr (future_get_param (future, 0)),
         future_value_get_bson_error_ptr (future_get_param (future, 1))
      ));

   future_resolve (future, return_value);

   return NULL;
}

static void *
background_mongoc_topology_select (void *data)
{
   future_t *future = (future_t *) data;
   future_value_t return_value;

   return_value.type = future_value_mongoc_server_description_ptr_type;

   future_value_set_mongoc_server_description_ptr (
      &return_value,
      mongoc_topology_select (
         future_value_get_mongoc_topology_ptr (future_get_param (future, 0)),
         future_value_get_mongoc_ss_optype_t (future_get_param (future, 1)),
         future_value_get_const_mongoc_read_prefs_ptr (future_get_param (future, 2)),
         future_value_get_int64_t (future_get_param (future, 3)),
         future_value_get_bson_error_ptr (future_get_param (future, 4))
      ));

   future_resolve (future, return_value);

   return NULL;
}



future_t *
future_bulk_operation_execute (
   mongoc_bulk_operation_ptr bulk,
   bson_ptr reply,
   bson_error_ptr error)
{
   future_t *future = future_new (future_value_uint32_t_type,
                                  3);
   
   future_value_set_mongoc_bulk_operation_ptr (
      future_get_param (future, 0), bulk);
   
   future_value_set_bson_ptr (
      future_get_param (future, 1), reply);
   
   future_value_set_bson_error_ptr (
      future_get_param (future, 2), error);
   
   future_start (future, background_mongoc_bulk_operation_execute);
   return future;
}

future_t *
future_client_command_simple (
   mongoc_client_ptr client,
   const_char_ptr db_name,
   const_bson_ptr command,
   const_mongoc_read_prefs_ptr read_prefs,
   bson_ptr reply,
   bson_error_ptr error)
{
   future_t *future = future_new (future_value_bool_type,
                                  6);
   
   future_value_set_mongoc_client_ptr (
      future_get_param (future, 0), client);
   
   future_value_set_const_char_ptr (
      future_get_param (future, 1), db_name);
   
   future_value_set_const_bson_ptr (
      future_get_param (future, 2), command);
   
   future_value_set_const_mongoc_read_prefs_ptr (
      future_get_param (future, 3), read_prefs);
   
   future_value_set_bson_ptr (
      future_get_param (future, 4), reply);
   
   future_value_set_bson_error_ptr (
      future_get_param (future, 5), error);
   
   future_start (future, background_mongoc_client_command_simple);
   return future;
}

future_t *
future_client_kill_cursor (
   mongoc_client_ptr client,
   int64_t cursor_id)
{
   future_t *future = future_new (future_value_void_type,
                                  2);
   
   future_value_set_mongoc_client_ptr (
      future_get_param (future, 0), client);
   
   future_value_set_int64_t (
      future_get_param (future, 1), cursor_id);
   
   future_start (future, background_mongoc_client_kill_cursor);
   return future;
}

future_t *
future_collection_aggregate (
   mongoc_collection_ptr collection,
   mongoc_query_flags_t flags,
   const_bson_ptr pipeline,
   const_bson_ptr options,
   const_mongoc_read_prefs_ptr read_prefs)
{
   future_t *future = future_new (future_value_mongoc_cursor_ptr_type,
                                  5);
   
   future_value_set_mongoc_collection_ptr (
      future_get_param (future, 0), collection);
   
   future_value_set_mongoc_query_flags_t (
      future_get_param (future, 1), flags);
   
   future_value_set_const_bson_ptr (
      future_get_param (future, 2), pipeline);
   
   future_value_set_const_bson_ptr (
      future_get_param (future, 3), options);
   
   future_value_set_const_mongoc_read_prefs_ptr (
      future_get_param (future, 4), read_prefs);
   
   future_start (future, background_mongoc_collection_aggregate);
   return future;
}

future_t *
future_collection_insert_bulk (
   mongoc_collection_ptr collection,
   mongoc_insert_flags_t flags,
   const_bson_ptr_ptr documents,
   uint32_t n_documents,
   const_mongoc_write_concern_ptr write_concern,
   bson_error_ptr error)
{
   future_t *future = future_new (future_value_bool_type,
                                  6);
   
   future_value_set_mongoc_collection_ptr (
      future_get_param (future, 0), collection);
   
   future_value_set_mongoc_insert_flags_t (
      future_get_param (future, 1), flags);
   
   future_value_set_const_bson_ptr_ptr (
      future_get_param (future, 2), documents);
   
   future_value_set_uint32_t (
      future_get_param (future, 3), n_documents);
   
   future_value_set_const_mongoc_write_concern_ptr (
      future_get_param (future, 4), write_concern);
   
   future_value_set_bson_error_ptr (
      future_get_param (future, 5), error);
   
   future_start (future, background_mongoc_collection_insert_bulk);
   return future;
}

future_t *
future_cursor_destroy (
   mongoc_cursor_ptr cursor)
{
   future_t *future = future_new (future_value_void_type,
                                  1);
   
   future_value_set_mongoc_cursor_ptr (
      future_get_param (future, 0), cursor);
   
   future_start (future, background_mongoc_cursor_destroy);
   return future;
}

future_t *
future_cursor_next (
   mongoc_cursor_ptr cursor,
   const_bson_ptr_ptr doc)
{
   future_t *future = future_new (future_value_bool_type,
                                  2);
   
   future_value_set_mongoc_cursor_ptr (
      future_get_param (future, 0), cursor);
   
   future_value_set_const_bson_ptr_ptr (
      future_get_param (future, 1), doc);
   
   future_start (future, background_mongoc_cursor_next);
   return future;
}

future_t *
future_client_get_database_names (
   mongoc_client_ptr client,
   bson_error_ptr error)
{
   future_t *future = future_new (future_value_char_ptr_ptr_type,
                                  2);
   
   future_value_set_mongoc_client_ptr (
      future_get_param (future, 0), client);
   
   future_value_set_bson_error_ptr (
      future_get_param (future, 1), error);
   
   future_start (future, background_mongoc_client_get_database_names);
   return future;
}

future_t *
future_database_get_collection_names (
   mongoc_database_ptr database,
   bson_error_ptr error)
{
   future_t *future = future_new (future_value_char_ptr_ptr_type,
                                  2);
   
   future_value_set_mongoc_database_ptr (
      future_get_param (future, 0), database);
   
   future_value_set_bson_error_ptr (
      future_get_param (future, 1), error);
   
   future_start (future, background_mongoc_database_get_collection_names);
   return future;
}

future_t *
future_topology_select (
   mongoc_topology_ptr topology,
   mongoc_ss_optype_t optype,
   const_mongoc_read_prefs_ptr read_prefs,
   int64_t local_threshold_ms,
   bson_error_ptr error)
{
   future_t *future = future_new (future_value_mongoc_server_description_ptr_type,
                                  5);
   
   future_value_set_mongoc_topology_ptr (
      future_get_param (future, 0), topology);
   
   future_value_set_mongoc_ss_optype_t (
      future_get_param (future, 1), optype);
   
   future_value_set_const_mongoc_read_prefs_ptr (
      future_get_param (future, 2), read_prefs);
   
   future_value_set_int64_t (
      future_get_param (future, 3), local_threshold_ms);
   
   future_value_set_bson_error_ptr (
      future_get_param (future, 4), error);
   
   future_start (future, background_mongoc_topology_select);
   return future;
}