-
Notifications
You must be signed in to change notification settings - Fork 0
/
AsyncList.h
37 lines (28 loc) · 1.28 KB
/
AsyncList.h
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
#ifndef INCLUDE_UTILITIES_ASYNCLIST
#define INCLUDE_UTILITIES_ASYNCLIST
#include "Common.h"
#include "List.h"
#include <SAL/Thread.h>
typedef struct AsyncList AsyncList;
typedef struct AsyncList_Iterator AsyncList_Iterator;
struct AsyncList {
List* BaseList;
SAL_Mutex Lock;
AsyncList_Iterator* DefaultIterator;
};
struct AsyncList_Iterator {
AsyncList* BaseList;
List_Iterator BaseIterator;
};
/* Iterates over every item in list using the list's DefaultIterator method. Resets the iterator upon invocation. Used like a while loop. */
#define AsyncList_ForEach(current, list, type) AsyncList_ResetIterator((list)->DefaultIterator); while ((current) = (type)AsyncList_Iterate((list)->DefaultIterator))
export AsyncList* AsyncList_New(List_ElementDisposer elementDisposer);
export void AsyncList_Initialize(AsyncList* list, List_ElementDisposer elementDisposer);
export void AsyncList_Free(AsyncList* self);
export void AsyncList_Uninitialize(AsyncList* self);
export void AsyncList_Append(AsyncList* self, void* data);
export uint64 AsyncList_GetCount(AsyncList* self);
export void* AsyncList_Iterate(AsyncList_Iterator* iterator);
export void AsyncList_InitializeIterator(AsyncList_Iterator* iterator, AsyncList* list);
export void AsyncList_ResetIterator(AsyncList_Iterator* iterator);
#endif