This file is indexed.

/usr/include/d/gtkd-3/glib/AsyncQueue.d is in libgtkd-3-dev 3.7.5-2build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
/*
 * This file is part of gtkD.
 *
 * gtkD is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 3
 * of the License, or (at your option) any later version, with
 * some exceptions, please read the COPYING file.
 *
 * gtkD is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with gtkD; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
 */

// generated automatically - do not change
// find conversion definition on APILookup.txt
// implement new conversion functionalities on the wrap.utils pakage


module glib.AsyncQueue;

private import glib.ConstructionException;
private import glib.TimeVal;
private import glib.c.functions;
public  import glib.c.types;
public  import gtkc.glibtypes;
private import gtkd.Loader;


/**
 * The GAsyncQueue struct is an opaque data structure which represents
 * an asynchronous queue. It should only be accessed through the
 * g_async_queue_* functions.
 */
public class AsyncQueue
{
	/** the main Gtk struct */
	protected GAsyncQueue* gAsyncQueue;
	protected bool ownedRef;

	/** Get the main Gtk struct */
	public GAsyncQueue* getAsyncQueueStruct(bool transferOwnership = false)
	{
		if (transferOwnership)
			ownedRef = false;
		return gAsyncQueue;
	}

	/** the main Gtk struct as a void* */
	protected void* getStruct()
	{
		return cast(void*)gAsyncQueue;
	}

	/**
	 * Sets our main struct and passes it to the parent class.
	 */
	public this (GAsyncQueue* gAsyncQueue, bool ownedRef = false)
	{
		this.gAsyncQueue = gAsyncQueue;
		this.ownedRef = ownedRef;
	}

	~this ()
	{
		if ( Linker.isLoaded(LIBRARY_GLIB) && ownedRef )
			g_async_queue_unref(gAsyncQueue);
	}


	/**
	 * Returns the length of the queue.
	 *
	 * Actually this function returns the number of data items in
	 * the queue minus the number of waiting threads, so a negative
	 * value means waiting threads, and a positive value means available
	 * entries in the @queue. A return value of 0 could mean n entries
	 * in the queue and n threads waiting. This can happen due to locking
	 * of the queue or due to scheduling.
	 *
	 * Returns: the length of the @queue
	 */
	public int length()
	{
		return g_async_queue_length(gAsyncQueue);
	}

	/**
	 * Returns the length of the queue.
	 *
	 * Actually this function returns the number of data items in
	 * the queue minus the number of waiting threads, so a negative
	 * value means waiting threads, and a positive value means available
	 * entries in the @queue. A return value of 0 could mean n entries
	 * in the queue and n threads waiting. This can happen due to locking
	 * of the queue or due to scheduling.
	 *
	 * This function must be called while holding the @queue's lock.
	 *
	 * Returns: the length of the @queue.
	 */
	public int lengthUnlocked()
	{
		return g_async_queue_length_unlocked(gAsyncQueue);
	}

	/**
	 * Acquires the @queue's lock. If another thread is already
	 * holding the lock, this call will block until the lock
	 * becomes available.
	 *
	 * Call g_async_queue_unlock() to drop the lock again.
	 *
	 * While holding the lock, you can only call the
	 * g_async_queue_*_unlocked() functions on @queue. Otherwise,
	 * deadlock may occur.
	 */
	public void lock()
	{
		g_async_queue_lock(gAsyncQueue);
	}

	/**
	 * Pops data from the @queue. If @queue is empty, this function
	 * blocks until data becomes available.
	 *
	 * Returns: data from the queue
	 */
	public void* pop()
	{
		return g_async_queue_pop(gAsyncQueue);
	}

	/**
	 * Pops data from the @queue. If @queue is empty, this function
	 * blocks until data becomes available.
	 *
	 * This function must be called while holding the @queue's lock.
	 *
	 * Returns: data from the queue.
	 */
	public void* popUnlocked()
	{
		return g_async_queue_pop_unlocked(gAsyncQueue);
	}

	/**
	 * Pushes the @data into the @queue. @data must not be %NULL.
	 *
	 * Params:
	 *     data = @data to push into the @queue
	 */
	public void push(void* data)
	{
		g_async_queue_push(gAsyncQueue, data);
	}

	/**
	 * Pushes the @item into the @queue. @item must not be %NULL.
	 * In contrast to g_async_queue_push(), this function
	 * pushes the new item ahead of the items already in the queue,
	 * so that it will be the next one to be popped off the queue.
	 *
	 * Params:
	 *     item = data to push into the @queue
	 *
	 * Since: 2.46
	 */
	public void pushFront(void* item)
	{
		g_async_queue_push_front(gAsyncQueue, item);
	}

	/**
	 * Pushes the @item into the @queue. @item must not be %NULL.
	 * In contrast to g_async_queue_push_unlocked(), this function
	 * pushes the new item ahead of the items already in the queue,
	 * so that it will be the next one to be popped off the queue.
	 *
	 * This function must be called while holding the @queue's lock.
	 *
	 * Params:
	 *     item = data to push into the @queue
	 *
	 * Since: 2.46
	 */
	public void pushFrontUnlocked(void* item)
	{
		g_async_queue_push_front_unlocked(gAsyncQueue, item);
	}

	/**
	 * Inserts @data into @queue using @func to determine the new
	 * position.
	 *
	 * This function requires that the @queue is sorted before pushing on
	 * new elements, see g_async_queue_sort().
	 *
	 * This function will lock @queue before it sorts the queue and unlock
	 * it when it is finished.
	 *
	 * For an example of @func see g_async_queue_sort().
	 *
	 * Params:
	 *     data = the @data to push into the @queue
	 *     func = the #GCompareDataFunc is used to sort @queue
	 *     userData = user data passed to @func.
	 *
	 * Since: 2.10
	 */
	public void pushSorted(void* data, GCompareDataFunc func, void* userData)
	{
		g_async_queue_push_sorted(gAsyncQueue, data, func, userData);
	}

	/**
	 * Inserts @data into @queue using @func to determine the new
	 * position.
	 *
	 * The sort function @func is passed two elements of the @queue.
	 * It should return 0 if they are equal, a negative value if the
	 * first element should be higher in the @queue or a positive value
	 * if the first element should be lower in the @queue than the second
	 * element.
	 *
	 * This function requires that the @queue is sorted before pushing on
	 * new elements, see g_async_queue_sort().
	 *
	 * This function must be called while holding the @queue's lock.
	 *
	 * For an example of @func see g_async_queue_sort().
	 *
	 * Params:
	 *     data = the @data to push into the @queue
	 *     func = the #GCompareDataFunc is used to sort @queue
	 *     userData = user data passed to @func.
	 *
	 * Since: 2.10
	 */
	public void pushSortedUnlocked(void* data, GCompareDataFunc func, void* userData)
	{
		g_async_queue_push_sorted_unlocked(gAsyncQueue, data, func, userData);
	}

	/**
	 * Pushes the @data into the @queue. @data must not be %NULL.
	 *
	 * This function must be called while holding the @queue's lock.
	 *
	 * Params:
	 *     data = @data to push into the @queue
	 */
	public void pushUnlocked(void* data)
	{
		g_async_queue_push_unlocked(gAsyncQueue, data);
	}

	/**
	 * Increases the reference count of the asynchronous @queue by 1.
	 * You do not need to hold the lock to call this function.
	 *
	 * Returns: the @queue that was passed in (since 2.6)
	 */
	public AsyncQueue doref()
	{
		auto p = g_async_queue_ref(gAsyncQueue);

		if(p is null)
		{
			return null;
		}

		return new AsyncQueue(cast(GAsyncQueue*) p);
	}

	/**
	 * Increases the reference count of the asynchronous @queue by 1.
	 *
	 * Deprecated: Reference counting is done atomically.
	 * so g_async_queue_ref() can be used regardless of the @queue's
	 * lock.
	 */
	public void refUnlocked()
	{
		g_async_queue_ref_unlocked(gAsyncQueue);
	}

	/**
	 * Remove an item from the queue.
	 *
	 * Params:
	 *     item = the data to remove from the @queue
	 *
	 * Returns: %TRUE if the item was removed
	 *
	 * Since: 2.46
	 */
	public bool remove(void* item)
	{
		return g_async_queue_remove(gAsyncQueue, item) != 0;
	}

	/**
	 * Remove an item from the queue.
	 *
	 * This function must be called while holding the @queue's lock.
	 *
	 * Params:
	 *     item = the data to remove from the @queue
	 *
	 * Returns: %TRUE if the item was removed
	 *
	 * Since: 2.46
	 */
	public bool removeUnlocked(void* item)
	{
		return g_async_queue_remove_unlocked(gAsyncQueue, item) != 0;
	}

	/**
	 * Sorts @queue using @func.
	 *
	 * The sort function @func is passed two elements of the @queue.
	 * It should return 0 if they are equal, a negative value if the
	 * first element should be higher in the @queue or a positive value
	 * if the first element should be lower in the @queue than the second
	 * element.
	 *
	 * This function will lock @queue before it sorts the queue and unlock
	 * it when it is finished.
	 *
	 * If you were sorting a list of priority numbers to make sure the
	 * lowest priority would be at the top of the queue, you could use:
	 * |[<!-- language="C" -->
	 * gint32 id1;
	 * gint32 id2;
	 *
	 * id1 = GPOINTER_TO_INT (element1);
	 * id2 = GPOINTER_TO_INT (element2);
	 *
	 * return (id1 > id2 ? +1 : id1 == id2 ? 0 : -1);
	 * ]|
	 *
	 * Params:
	 *     func = the #GCompareDataFunc is used to sort @queue
	 *     userData = user data passed to @func
	 *
	 * Since: 2.10
	 */
	public void sort(GCompareDataFunc func, void* userData)
	{
		g_async_queue_sort(gAsyncQueue, func, userData);
	}

	/**
	 * Sorts @queue using @func.
	 *
	 * The sort function @func is passed two elements of the @queue.
	 * It should return 0 if they are equal, a negative value if the
	 * first element should be higher in the @queue or a positive value
	 * if the first element should be lower in the @queue than the second
	 * element.
	 *
	 * This function must be called while holding the @queue's lock.
	 *
	 * Params:
	 *     func = the #GCompareDataFunc is used to sort @queue
	 *     userData = user data passed to @func
	 *
	 * Since: 2.10
	 */
	public void sortUnlocked(GCompareDataFunc func, void* userData)
	{
		g_async_queue_sort_unlocked(gAsyncQueue, func, userData);
	}

	/**
	 * Pops data from the @queue. If the queue is empty, blocks until
	 * @end_time or until data becomes available.
	 *
	 * If no data is received before @end_time, %NULL is returned.
	 *
	 * To easily calculate @end_time, a combination of g_get_current_time()
	 * and g_time_val_add() can be used.
	 *
	 * Deprecated: use g_async_queue_timeout_pop().
	 *
	 * Params:
	 *     endTime = a #GTimeVal, determining the final time
	 *
	 * Returns: data from the queue or %NULL, when no data is
	 *     received before @end_time.
	 */
	public void* timedPop(TimeVal endTime)
	{
		return g_async_queue_timed_pop(gAsyncQueue, (endTime is null) ? null : endTime.getTimeValStruct());
	}

	/**
	 * Pops data from the @queue. If the queue is empty, blocks until
	 * @end_time or until data becomes available.
	 *
	 * If no data is received before @end_time, %NULL is returned.
	 *
	 * To easily calculate @end_time, a combination of g_get_current_time()
	 * and g_time_val_add() can be used.
	 *
	 * This function must be called while holding the @queue's lock.
	 *
	 * Deprecated: use g_async_queue_timeout_pop_unlocked().
	 *
	 * Params:
	 *     endTime = a #GTimeVal, determining the final time
	 *
	 * Returns: data from the queue or %NULL, when no data is
	 *     received before @end_time.
	 */
	public void* timedPopUnlocked(TimeVal endTime)
	{
		return g_async_queue_timed_pop_unlocked(gAsyncQueue, (endTime is null) ? null : endTime.getTimeValStruct());
	}

	/**
	 * Pops data from the @queue. If the queue is empty, blocks for
	 * @timeout microseconds, or until data becomes available.
	 *
	 * If no data is received before the timeout, %NULL is returned.
	 *
	 * Params:
	 *     timeout = the number of microseconds to wait
	 *
	 * Returns: data from the queue or %NULL, when no data is
	 *     received before the timeout.
	 */
	public void* timeoutPop(ulong timeout)
	{
		return g_async_queue_timeout_pop(gAsyncQueue, timeout);
	}

	/**
	 * Pops data from the @queue. If the queue is empty, blocks for
	 * @timeout microseconds, or until data becomes available.
	 *
	 * If no data is received before the timeout, %NULL is returned.
	 *
	 * This function must be called while holding the @queue's lock.
	 *
	 * Params:
	 *     timeout = the number of microseconds to wait
	 *
	 * Returns: data from the queue or %NULL, when no data is
	 *     received before the timeout.
	 */
	public void* timeoutPopUnlocked(ulong timeout)
	{
		return g_async_queue_timeout_pop_unlocked(gAsyncQueue, timeout);
	}

	/**
	 * Tries to pop data from the @queue. If no data is available,
	 * %NULL is returned.
	 *
	 * Returns: data from the queue or %NULL, when no data is
	 *     available immediately.
	 */
	public void* tryPop()
	{
		return g_async_queue_try_pop(gAsyncQueue);
	}

	/**
	 * Tries to pop data from the @queue. If no data is available,
	 * %NULL is returned.
	 *
	 * This function must be called while holding the @queue's lock.
	 *
	 * Returns: data from the queue or %NULL, when no data is
	 *     available immediately.
	 */
	public void* tryPopUnlocked()
	{
		return g_async_queue_try_pop_unlocked(gAsyncQueue);
	}

	/**
	 * Releases the queue's lock.
	 *
	 * Calling this function when you have not acquired
	 * the with g_async_queue_lock() leads to undefined
	 * behaviour.
	 */
	public void unlock()
	{
		g_async_queue_unlock(gAsyncQueue);
	}

	/**
	 * Decreases the reference count of the asynchronous @queue by 1.
	 *
	 * If the reference count went to 0, the @queue will be destroyed
	 * and the memory allocated will be freed. So you are not allowed
	 * to use the @queue afterwards, as it might have disappeared.
	 * You do not need to hold the lock to call this function.
	 */
	public void unref()
	{
		g_async_queue_unref(gAsyncQueue);
	}

	/**
	 * Decreases the reference count of the asynchronous @queue by 1
	 * and releases the lock. This function must be called while holding
	 * the @queue's lock. If the reference count went to 0, the @queue
	 * will be destroyed and the memory allocated will be freed.
	 *
	 * Deprecated: Reference counting is done atomically.
	 * so g_async_queue_unref() can be used regardless of the @queue's
	 * lock.
	 */
	public void unrefAndUnlock()
	{
		g_async_queue_unref_and_unlock(gAsyncQueue);
	}

	/**
	 * Creates a new asynchronous queue.
	 *
	 * Returns: a new #GAsyncQueue. Free with g_async_queue_unref()
	 *
	 * Throws: ConstructionException GTK+ fails to create the object.
	 */
	public this()
	{
		auto p = g_async_queue_new();

		if(p is null)
		{
			throw new ConstructionException("null returned by new");
		}

		this(cast(GAsyncQueue*) p);
	}

	/**
	 * Creates a new asynchronous queue and sets up a destroy notify
	 * function that is used to free any remaining queue items when
	 * the queue is destroyed after the final unref.
	 *
	 * Params:
	 *     itemFreeFunc = function to free queue elements
	 *
	 * Returns: a new #GAsyncQueue. Free with g_async_queue_unref()
	 *
	 * Since: 2.16
	 *
	 * Throws: ConstructionException GTK+ fails to create the object.
	 */
	public this(GDestroyNotify itemFreeFunc)
	{
		auto p = g_async_queue_new_full(itemFreeFunc);

		if(p is null)
		{
			throw new ConstructionException("null returned by new_full");
		}

		this(cast(GAsyncQueue*) p);
	}
}