root/Whitix/trunk/kernel/completion.c

Revision 2025, 0.6 KB (checked in by mwhitworth, 3 years ago)

Add beginning of completion API.

Line 
1#include <completion.h>
2#include <module.h>
3#include <task.h>
4#include <wait.h>
5
6inline int CompletionIsDone(struct Completion* comp)
7{
8        return comp->done;
9}
10
11SYMBOL_EXPORT(CompletionIsDone);
12
13int CompletionWaitEx(struct Completion* comp, int timeout)
14{
15        if (!comp->done)
16        {
17                /* FIXME: Add timeout. */
18                WAIT_ON(&comp->waitQueue, CompletionIsDone(comp));
19        }
20       
21        comp->done--;
22       
23        return 0;
24}
25
26SYMBOL_EXPORT(CompletionWaitEx);
27
28void CompletionDone(struct Completion* comp)
29{
30        DWORD flags;
31
32        IrqSaveFlags(flags);
33
34        comp->done++;
35        WakeUpAll(&comp->waitQueue);
36
37        IrqRestoreFlags(flags);
38}
39
40SYMBOL_EXPORT(CompletionDone);
Note: See TracBrowser for help on using the browser.