FreeRDP
apc.h
1 
20 #ifndef WINPR_APC_H
21 #define WINPR_APC_H
22 
23 #include <winpr/winpr.h>
24 #include <winpr/wtypes.h>
25 
26 #ifndef _WIN32
27 
28 #include <pthread.h>
29 
30 typedef struct winpr_thread WINPR_THREAD;
31 typedef struct winpr_APC_item WINPR_APC_ITEM;
32 typedef struct winpr_poll_set WINPR_POLL_SET;
33 
34 typedef void (*apc_treatment)(LPVOID arg);
35 
36 typedef enum
37 {
38  APC_TYPE_USER,
39  APC_TYPE_TIMER,
40  APC_TYPE_HANDLE_FREE
41 } ApcType;
42 
44 {
45  ApcType type;
46  int pollFd;
47  DWORD pollMode;
48  apc_treatment completion;
49  LPVOID completionArgs;
50  BOOL markedForFree;
51 
52  /* private fields used by the APC */
53  BOOL alwaysSignaled;
54  BOOL isSignaled;
55  DWORD boundThread;
56  BOOL linked;
57  BOOL markedForRemove;
58  WINPR_APC_ITEM *last, *next;
59 };
60 
61 typedef enum
62 {
63  APC_REMOVE_OK,
64  APC_REMOVE_ERROR,
65  APC_REMOVE_DELAY_FREE
66 } APC_REMOVE_RESULT;
67 
68 typedef struct
69 {
70  pthread_mutex_t mutex;
71  DWORD length;
72  WINPR_APC_ITEM *head, *tail;
73  BOOL treatingCompletions;
74 } APC_QUEUE;
75 
76 BOOL apc_init(APC_QUEUE* apc);
77 BOOL apc_uninit(APC_QUEUE* apc);
78 void apc_register(WINPR_THREAD* thread, WINPR_APC_ITEM* addItem);
79 APC_REMOVE_RESULT apc_remove(WINPR_APC_ITEM* item);
80 BOOL apc_collectFds(WINPR_THREAD* thread, WINPR_POLL_SET* set, BOOL* haveAutoSignaled);
81 int apc_executeCompletions(WINPR_THREAD* thread, WINPR_POLL_SET* set, size_t startIndex);
82 void apc_cleanupThread(WINPR_THREAD* thread);
83 #endif
84 
85 #endif /* WINPR_APC_H */
Definition: apc.h:69