File: queue.h

package info (click to toggle)
fvwm 1:2.6.8-1
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 15,804 kB
  • sloc: ansic: 145,770; xml: 17,093; perl: 7,302; sh: 4,921; makefile: 1,094; yacc: 688; lex: 187; sed: 11
file content (77 lines) | stat: -rw-r--r-- 1,759 bytes parent folder | download | duplicates (9)
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
/* -*-c-*- */

#ifndef QUEUE_H
#define QUEUE_H

/*
 * type definitions
 */

typedef struct
{
	/* do not read or write any members of this structure outside queue.c!
	 */
	struct fqueue_record *first;
	struct fqueue_record *last;
	unsigned int lock_level;
	struct
	{
		unsigned is_dirty : 1;
	} flags;
} fqueue;
#define FQUEUE_INIT { NULL, NULL, 0 }



typedef int (*check_fqueue_object_t)(void *object, void *operate_args);
typedef void (*operate_fqueue_object_t)(void *object, void *operate_args);
typedef int (*cmp_objects_t)(void *object1, void *object2, void *args);
typedef void (*destroy_fqueue_object_t)(void *object);

/*
 * Basic queue management
 */

void fqueue_init(fqueue *fq);
unsigned int fqueue_get_length(fqueue *fq);
#define FQUEUE_IS_EMPTY(fq) ((fq)->first == NULL)

/*
 * Add record to queue
 */

void fqueue_add_at_front(fqueue *fq, void *object);
void fqueue_add_at_end(fqueue *fq, void *object);
void fqueue_add_inside(
	fqueue *fq, void *object, cmp_objects_t cmp_objects, void *cmp_args);

/*
 * Fetch queue objects
 */

int fqueue_get_first(fqueue *fq, void **ret_object);

/*
 * Operate on queue objects and possibly remove them from the queue
 */

void fqueue_remove_or_operate_from_front(
	fqueue *fq,
	check_fqueue_object_t check_func,
	operate_fqueue_object_t operate_func,
	destroy_fqueue_object_t destroy_func,
	void *operate_args);
void fqueue_remove_or_operate_from_end(
	fqueue *fq,
	check_fqueue_object_t check_func,
	operate_fqueue_object_t operate_func,
	destroy_fqueue_object_t destroy_func,
	void *operate_args);
void fqueue_remove_or_operate_all(
	fqueue *fq,
	check_fqueue_object_t check_func,
	operate_fqueue_object_t operate_func,
	destroy_fqueue_object_t destroy_func,
	void *operate_args);

#endif /* QUEUE_H */