v0.2.2 9100209

gasyncqueue.go RawHistoryFolder

1// Package glib was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package glib
3
4import (
5	"structs"
6	"unsafe"
7
8	"github.com/ebitengine/purego"
9
10	"github.com/bnema/puregotk/pkg/core"
11)
12
13// An opaque data structure which represents an asynchronous queue.
14//
15// It should only be accessed through the `g_async_queue_*` functions.
16type AsyncQueue struct {
17	_ structs.HostLayout
18}
19
20func (x *AsyncQueue) GoPointer() uintptr {
21	return uintptr(unsafe.Pointer(x))
22}
23
24var xAsyncQueueLength func(uintptr) int
25
26// Returns the length of the queue.
27//
28// Actually this function returns the number of data items in
29// the queue minus the number of waiting threads, so a negative
30// value means waiting threads, and a positive value means available
31// entries in the @queue. A return value of 0 could mean n entries
32// in the queue and n threads waiting. This can happen due to locking
33// of the queue or due to scheduling.
34func (x *AsyncQueue) Length() int {
35
36	cret := xAsyncQueueLength(x.GoPointer())
37	return cret
38}
39
40var xAsyncQueueLengthUnlocked func(uintptr) int
41
42// Returns the length of the queue.
43//
44// Actually this function returns the number of data items in
45// the queue minus the number of waiting threads, so a negative
46// value means waiting threads, and a positive value means available
47// entries in the @queue. A return value of 0 could mean n entries
48// in the queue and n threads waiting. This can happen due to locking
49// of the queue or due to scheduling.
50//
51// This function must be called while holding the @queue's lock.
52func (x *AsyncQueue) LengthUnlocked() int {
53
54	cret := xAsyncQueueLengthUnlocked(x.GoPointer())
55	return cret
56}
57
58var xAsyncQueueLock func(uintptr)
59
60// Acquires the @queue's lock. If another thread is already
61// holding the lock, this call will block until the lock
62// becomes available.
63//
64// Call g_async_queue_unlock() to drop the lock again.
65//
66// While holding the lock, you can only call the
67// g_async_queue_*_unlocked() functions on @queue. Otherwise,
68// deadlock may occur.
69func (x *AsyncQueue) Lock() {
70
71	xAsyncQueueLock(x.GoPointer())
72
73}
74
75var xAsyncQueuePop func(uintptr) uintptr
76
77// Pops data from the @queue. If @queue is empty, this function
78// blocks until data becomes available.
79func (x *AsyncQueue) Pop() uintptr {
80
81	cret := xAsyncQueuePop(x.GoPointer())
82	return cret
83}
84
85var xAsyncQueuePopUnlocked func(uintptr) uintptr
86
87// Pops data from the @queue. If @queue is empty, this function
88// blocks until data becomes available.
89//
90// This function must be called while holding the @queue's lock.
91func (x *AsyncQueue) PopUnlocked() uintptr {
92
93	cret := xAsyncQueuePopUnlocked(x.GoPointer())
94	return cret
95}
96
97var xAsyncQueuePush func(uintptr, uintptr)
98
99// Pushes the @data into the @queue.
100//
101// The @data parameter must not be %NULL.
102func (x *AsyncQueue) Push(DataVar uintptr) {
103
104	xAsyncQueuePush(x.GoPointer(), DataVar)
105
106}
107
108var xAsyncQueuePushFront func(uintptr, uintptr)
109
110// Pushes the @item into the @queue. @item must not be %NULL.
111// In contrast to g_async_queue_push(), this function
112// pushes the new item ahead of the items already in the queue,
113// so that it will be the next one to be popped off the queue.
114func (x *AsyncQueue) PushFront(ItemVar uintptr) {
115
116	xAsyncQueuePushFront(x.GoPointer(), ItemVar)
117
118}
119
120var xAsyncQueuePushFrontUnlocked func(uintptr, uintptr)
121
122// Pushes the @item into the @queue. @item must not be %NULL.
123// In contrast to g_async_queue_push_unlocked(), this function
124// pushes the new item ahead of the items already in the queue,
125// so that it will be the next one to be popped off the queue.
126//
127// This function must be called while holding the @queue's lock.
128func (x *AsyncQueue) PushFrontUnlocked(ItemVar uintptr) {
129
130	xAsyncQueuePushFrontUnlocked(x.GoPointer(), ItemVar)
131
132}
133
134var xAsyncQueuePushSorted func(uintptr, uintptr, uintptr, uintptr)
135
136// Inserts @data into @queue using @func to determine the new
137// position.
138//
139// This function requires that the @queue is sorted before pushing on
140// new elements, see g_async_queue_sort().
141//
142// This function will lock @queue before it sorts the queue and unlock
143// it when it is finished.
144//
145// For an example of @func see g_async_queue_sort().
146func (x *AsyncQueue) PushSorted(DataVar uintptr, FuncVar *CompareDataFunc, UserDataVar uintptr) {
147
148	var FuncVarRef uintptr
149	if FuncVar != nil {
150		FuncVarPtr := uintptr(unsafe.Pointer(FuncVar))
151		if cbRefPtr, ok := GetCallback(FuncVarPtr); ok {
152			FuncVarRef = cbRefPtr
153		} else {
154			fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) int {
155				cbFn := *FuncVar
156				return cbFn(arg0, arg1, arg2)
157			}
158			FuncVarRef = purego.NewCallback(fcb)
159			SaveCallbackWithClosure(FuncVarPtr, FuncVarRef, FuncVar)
160		}
161	}
162
163	xAsyncQueuePushSorted(x.GoPointer(), DataVar, FuncVarRef, UserDataVar)
164
165}
166
167var xAsyncQueuePushSortedUnlocked func(uintptr, uintptr, uintptr, uintptr)
168
169// Inserts @data into @queue using @func to determine the new
170// position.
171//
172// The sort function @func is passed two elements of the @queue.
173// It should return 0 if they are equal, a negative value if the
174// first element should be higher in the @queue or a positive value
175// if the first element should be lower in the @queue than the second
176// element.
177//
178// This function requires that the @queue is sorted before pushing on
179// new elements, see g_async_queue_sort().
180//
181// This function must be called while holding the @queue's lock.
182//
183// For an example of @func see g_async_queue_sort().
184func (x *AsyncQueue) PushSortedUnlocked(DataVar uintptr, FuncVar *CompareDataFunc, UserDataVar uintptr) {
185
186	var FuncVarRef uintptr
187	if FuncVar != nil {
188		FuncVarPtr := uintptr(unsafe.Pointer(FuncVar))
189		if cbRefPtr, ok := GetCallback(FuncVarPtr); ok {
190			FuncVarRef = cbRefPtr
191		} else {
192			fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) int {
193				cbFn := *FuncVar
194				return cbFn(arg0, arg1, arg2)
195			}
196			FuncVarRef = purego.NewCallback(fcb)
197			SaveCallbackWithClosure(FuncVarPtr, FuncVarRef, FuncVar)
198		}
199	}
200
201	xAsyncQueuePushSortedUnlocked(x.GoPointer(), DataVar, FuncVarRef, UserDataVar)
202
203}
204
205var xAsyncQueuePushUnlocked func(uintptr, uintptr)
206
207// Pushes the @data into the @queue.
208//
209// The @data parameter must not be %NULL.
210//
211// This function must be called while holding the @queue's lock.
212func (x *AsyncQueue) PushUnlocked(DataVar uintptr) {
213
214	xAsyncQueuePushUnlocked(x.GoPointer(), DataVar)
215
216}
217
218var xAsyncQueueRef func(uintptr) *AsyncQueue
219
220// Increases the reference count of the asynchronous @queue by 1.
221// You do not need to hold the lock to call this function.
222func (x *AsyncQueue) Ref() *AsyncQueue {
223
224	cret := xAsyncQueueRef(x.GoPointer())
225	return cret
226}
227
228var xAsyncQueueRefUnlocked func(uintptr)
229
230// Increases the reference count of the asynchronous @queue by 1.
231func (x *AsyncQueue) RefUnlocked() {
232
233	xAsyncQueueRefUnlocked(x.GoPointer())
234
235}
236
237var xAsyncQueueRemove func(uintptr, uintptr) bool
238
239// Remove an item from the queue.
240func (x *AsyncQueue) Remove(ItemVar uintptr) bool {
241
242	cret := xAsyncQueueRemove(x.GoPointer(), ItemVar)
243	return cret
244}
245
246var xAsyncQueueRemoveUnlocked func(uintptr, uintptr) bool
247
248// Remove an item from the queue.
249//
250// This function must be called while holding the @queue's lock.
251func (x *AsyncQueue) RemoveUnlocked(ItemVar uintptr) bool {
252
253	cret := xAsyncQueueRemoveUnlocked(x.GoPointer(), ItemVar)
254	return cret
255}
256
257var xAsyncQueueSort func(uintptr, uintptr, uintptr)
258
259// Sorts @queue using @func.
260//
261// The sort function @func is passed two elements of the @queue.
262// It should return 0 if they are equal, a negative value if the
263// first element should be higher in the @queue or a positive value
264// if the first element should be lower in the @queue than the second
265// element.
266//
267// This function will lock @queue before it sorts the queue and unlock
268// it when it is finished.
269//
270// If you were sorting a list of priority numbers to make sure the
271// lowest priority would be at the top of the queue, you could use:
272// |[<!-- language="C" -->
273//
274//	gint32 id1;
275//	gint32 id2;
276//
277//	id1 = GPOINTER_TO_INT (element1);
278//	id2 = GPOINTER_TO_INT (element2);
279//
280//	return (id1 > id2 ? +1 : id1 == id2 ? 0 : -1);
281//
282// ]|
283func (x *AsyncQueue) Sort(FuncVar *CompareDataFunc, UserDataVar uintptr) {
284
285	var FuncVarRef uintptr
286	if FuncVar != nil {
287		FuncVarPtr := uintptr(unsafe.Pointer(FuncVar))
288		if cbRefPtr, ok := GetCallback(FuncVarPtr); ok {
289			FuncVarRef = cbRefPtr
290		} else {
291			fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) int {
292				cbFn := *FuncVar
293				return cbFn(arg0, arg1, arg2)
294			}
295			FuncVarRef = purego.NewCallback(fcb)
296			SaveCallbackWithClosure(FuncVarPtr, FuncVarRef, FuncVar)
297		}
298	}
299
300	xAsyncQueueSort(x.GoPointer(), FuncVarRef, UserDataVar)
301
302}
303
304var xAsyncQueueSortUnlocked func(uintptr, uintptr, uintptr)
305
306// Sorts @queue using @func.
307//
308// The sort function @func is passed two elements of the @queue.
309// It should return 0 if they are equal, a negative value if the
310// first element should be higher in the @queue or a positive value
311// if the first element should be lower in the @queue than the second
312// element.
313//
314// This function must be called while holding the @queue's lock.
315func (x *AsyncQueue) SortUnlocked(FuncVar *CompareDataFunc, UserDataVar uintptr) {
316
317	var FuncVarRef uintptr
318	if FuncVar != nil {
319		FuncVarPtr := uintptr(unsafe.Pointer(FuncVar))
320		if cbRefPtr, ok := GetCallback(FuncVarPtr); ok {
321			FuncVarRef = cbRefPtr
322		} else {
323			fcb := func(arg0 uintptr, arg1 uintptr, arg2 uintptr) int {
324				cbFn := *FuncVar
325				return cbFn(arg0, arg1, arg2)
326			}
327			FuncVarRef = purego.NewCallback(fcb)
328			SaveCallbackWithClosure(FuncVarPtr, FuncVarRef, FuncVar)
329		}
330	}
331
332	xAsyncQueueSortUnlocked(x.GoPointer(), FuncVarRef, UserDataVar)
333
334}
335
336var xAsyncQueueTimedPop func(uintptr, *TimeVal) uintptr
337
338// Pops data from the @queue. If the queue is empty, blocks until
339// @end_time or until data becomes available.
340//
341// If no data is received before @end_time, %NULL is returned.
342//
343// To easily calculate @end_time, a combination of g_get_real_time()
344// and g_time_val_add() can be used.
345func (x *AsyncQueue) TimedPop(EndTimeVar *TimeVal) uintptr {
346
347	cret := xAsyncQueueTimedPop(x.GoPointer(), EndTimeVar)
348	return cret
349}
350
351var xAsyncQueueTimedPopUnlocked func(uintptr, *TimeVal) uintptr
352
353// Pops data from the @queue. If the queue is empty, blocks until
354// @end_time or until data becomes available.
355//
356// If no data is received before @end_time, %NULL is returned.
357//
358// To easily calculate @end_time, a combination of g_get_real_time()
359// and g_time_val_add() can be used.
360//
361// This function must be called while holding the @queue's lock.
362func (x *AsyncQueue) TimedPopUnlocked(EndTimeVar *TimeVal) uintptr {
363
364	cret := xAsyncQueueTimedPopUnlocked(x.GoPointer(), EndTimeVar)
365	return cret
366}
367
368var xAsyncQueueTimeoutPop func(uintptr, uint64) uintptr
369
370// Pops data from the @queue. If the queue is empty, blocks for
371// @timeout microseconds, or until data becomes available.
372//
373// If no data is received before the timeout, %NULL is returned.
374func (x *AsyncQueue) TimeoutPop(TimeoutVar uint64) uintptr {
375
376	cret := xAsyncQueueTimeoutPop(x.GoPointer(), TimeoutVar)
377	return cret
378}
379
380var xAsyncQueueTimeoutPopUnlocked func(uintptr, uint64) uintptr
381
382// Pops data from the @queue. If the queue is empty, blocks for
383// @timeout microseconds, or until data becomes available.
384//
385// If no data is received before the timeout, %NULL is returned.
386//
387// This function must be called while holding the @queue's lock.
388func (x *AsyncQueue) TimeoutPopUnlocked(TimeoutVar uint64) uintptr {
389
390	cret := xAsyncQueueTimeoutPopUnlocked(x.GoPointer(), TimeoutVar)
391	return cret
392}
393
394var xAsyncQueueTryPop func(uintptr) uintptr
395
396// Tries to pop data from the @queue. If no data is available,
397// %NULL is returned.
398func (x *AsyncQueue) TryPop() uintptr {
399
400	cret := xAsyncQueueTryPop(x.GoPointer())
401	return cret
402}
403
404var xAsyncQueueTryPopUnlocked func(uintptr) uintptr
405
406// Tries to pop data from the @queue. If no data is available,
407// %NULL is returned.
408//
409// This function must be called while holding the @queue's lock.
410func (x *AsyncQueue) TryPopUnlocked() uintptr {
411
412	cret := xAsyncQueueTryPopUnlocked(x.GoPointer())
413	return cret
414}
415
416var xAsyncQueueUnlock func(uintptr)
417
418// Releases the queue's lock.
419//
420// Calling this function when you have not acquired
421// the with g_async_queue_lock() leads to undefined
422// behaviour.
423func (x *AsyncQueue) Unlock() {
424
425	xAsyncQueueUnlock(x.GoPointer())
426
427}
428
429var xAsyncQueueUnref func(uintptr)
430
431// Decreases the reference count of the asynchronous @queue by 1.
432//
433// If the reference count went to 0, the @queue will be destroyed
434// and the memory allocated will be freed. So you are not allowed
435// to use the @queue afterwards, as it might have disappeared.
436// You do not need to hold the lock to call this function.
437func (x *AsyncQueue) Unref() {
438
439	xAsyncQueueUnref(x.GoPointer())
440
441}
442
443var xAsyncQueueUnrefAndUnlock func(uintptr)
444
445// Decreases the reference count of the asynchronous @queue by 1
446// and releases the lock. This function must be called while holding
447// the @queue's lock. If the reference count went to 0, the @queue
448// will be destroyed and the memory allocated will be freed.
449func (x *AsyncQueue) UnrefAndUnlock() {
450
451	xAsyncQueueUnrefAndUnlock(x.GoPointer())
452
453}
454
455var xAsyncQueueNew func() *AsyncQueue
456
457// Creates a new asynchronous queue.
458func AsyncQueueNew() *AsyncQueue {
459
460	cret := xAsyncQueueNew()
461
462	return cret
463}
464
465var xAsyncQueueNewFull func(uintptr) *AsyncQueue
466
467// Creates a new asynchronous queue and sets up a destroy notify
468// function that is used to free any remaining queue items when
469// the queue is destroyed after the final unref.
470func AsyncQueueNewFull(ItemFreeFuncVar *DestroyNotify) *AsyncQueue {
471
472	var ItemFreeFuncVarRef uintptr
473	if ItemFreeFuncVar != nil {
474		ItemFreeFuncVarPtr := uintptr(unsafe.Pointer(ItemFreeFuncVar))
475		if cbRefPtr, ok := GetCallback(ItemFreeFuncVarPtr); ok {
476			ItemFreeFuncVarRef = cbRefPtr
477		} else {
478			fcb := func(arg0 uintptr) {
479				cbFn := *ItemFreeFuncVar
480				cbFn(arg0)
481			}
482			ItemFreeFuncVarRef = purego.NewCallback(fcb)
483			SaveCallbackWithClosure(ItemFreeFuncVarPtr, ItemFreeFuncVarRef, ItemFreeFuncVar)
484		}
485	}
486
487	cret := xAsyncQueueNewFull(ItemFreeFuncVarRef)
488
489	return cret
490}
491
492func init() {
493	core.SetPackageName("GLIB", "glib-2.0")
494	core.SetSharedLibraries("GLIB", []string{"libgobject-2.0.so.0", "libglib-2.0.so.0"})
495	var libs []uintptr
496	for _, libPath := range core.GetPaths("GLIB") {
497		lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
498		if err != nil {
499			panic(err)
500		}
501		libs = append(libs, lib)
502	}
503
504	core.PuregoSafeRegister(&xAsyncQueueNew, libs, "g_async_queue_new")
505	core.PuregoSafeRegister(&xAsyncQueueNewFull, libs, "g_async_queue_new_full")
506
507	core.PuregoSafeRegister(&xAsyncQueueLength, libs, "g_async_queue_length")
508	core.PuregoSafeRegister(&xAsyncQueueLengthUnlocked, libs, "g_async_queue_length_unlocked")
509	core.PuregoSafeRegister(&xAsyncQueueLock, libs, "g_async_queue_lock")
510	core.PuregoSafeRegister(&xAsyncQueuePop, libs, "g_async_queue_pop")
511	core.PuregoSafeRegister(&xAsyncQueuePopUnlocked, libs, "g_async_queue_pop_unlocked")
512	core.PuregoSafeRegister(&xAsyncQueuePush, libs, "g_async_queue_push")
513	core.PuregoSafeRegister(&xAsyncQueuePushFront, libs, "g_async_queue_push_front")
514	core.PuregoSafeRegister(&xAsyncQueuePushFrontUnlocked, libs, "g_async_queue_push_front_unlocked")
515	core.PuregoSafeRegister(&xAsyncQueuePushSorted, libs, "g_async_queue_push_sorted")
516	core.PuregoSafeRegister(&xAsyncQueuePushSortedUnlocked, libs, "g_async_queue_push_sorted_unlocked")
517	core.PuregoSafeRegister(&xAsyncQueuePushUnlocked, libs, "g_async_queue_push_unlocked")
518	core.PuregoSafeRegister(&xAsyncQueueRef, libs, "g_async_queue_ref")
519	core.PuregoSafeRegister(&xAsyncQueueRefUnlocked, libs, "g_async_queue_ref_unlocked")
520	core.PuregoSafeRegister(&xAsyncQueueRemove, libs, "g_async_queue_remove")
521	core.PuregoSafeRegister(&xAsyncQueueRemoveUnlocked, libs, "g_async_queue_remove_unlocked")
522	core.PuregoSafeRegister(&xAsyncQueueSort, libs, "g_async_queue_sort")
523	core.PuregoSafeRegister(&xAsyncQueueSortUnlocked, libs, "g_async_queue_sort_unlocked")
524	core.PuregoSafeRegister(&xAsyncQueueTimedPop, libs, "g_async_queue_timed_pop")
525	core.PuregoSafeRegister(&xAsyncQueueTimedPopUnlocked, libs, "g_async_queue_timed_pop_unlocked")
526	core.PuregoSafeRegister(&xAsyncQueueTimeoutPop, libs, "g_async_queue_timeout_pop")
527	core.PuregoSafeRegister(&xAsyncQueueTimeoutPopUnlocked, libs, "g_async_queue_timeout_pop_unlocked")
528	core.PuregoSafeRegister(&xAsyncQueueTryPop, libs, "g_async_queue_try_pop")
529	core.PuregoSafeRegister(&xAsyncQueueTryPopUnlocked, libs, "g_async_queue_try_pop_unlocked")
530	core.PuregoSafeRegister(&xAsyncQueueUnlock, libs, "g_async_queue_unlock")
531	core.PuregoSafeRegister(&xAsyncQueueUnref, libs, "g_async_queue_unref")
532	core.PuregoSafeRegister(&xAsyncQueueUnrefAndUnlock, libs, "g_async_queue_unref_and_unlock")
533
534}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 102

↑↓ moveenter openesc close