diff options
author | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2021-12-27 00:00:00 +0000 |
---|---|---|
committer | Igor Pavlov <87184205+ip7z@users.noreply.github.com> | 2022-03-18 15:35:13 +0500 |
commit | f19f813537c7aea1c20749c914e756b54a9c3cf5 (patch) | |
tree | 816ba62ca7c0fa19f2eb46d9e9d6f7dd7c3a744d /CPP/Windows/Synchronization.cpp | |
parent | 98e06a519b63b81986abe76d28887f6984a7732b (diff) | |
download | 7zip-21.07.tar.gz 7zip-21.07.tar.bz2 7zip-21.07.zip |
'21.07'21.07
Diffstat (limited to 'CPP/Windows/Synchronization.cpp')
-rw-r--r-- | CPP/Windows/Synchronization.cpp | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/CPP/Windows/Synchronization.cpp b/CPP/Windows/Synchronization.cpp new file mode 100644 index 0000000..fbf919d --- /dev/null +++ b/CPP/Windows/Synchronization.cpp | |||
@@ -0,0 +1,63 @@ | |||
1 | // Windows/Synchronization.cpp | ||
2 | |||
3 | #include "StdAfx.h" | ||
4 | |||
5 | #ifndef _WIN32 | ||
6 | |||
7 | #include "Synchronization.h" | ||
8 | |||
9 | namespace NWindows { | ||
10 | namespace NSynchronization { | ||
11 | |||
12 | /* | ||
13 | #define INFINITE 0xFFFFFFFF | ||
14 | #define MAXIMUM_WAIT_OBJECTS 64 | ||
15 | #define STATUS_ABANDONED_WAIT_0 ((NTSTATUS)0x00000080L) | ||
16 | #define WAIT_ABANDONED ((STATUS_ABANDONED_WAIT_0 ) + 0 ) | ||
17 | #define WAIT_ABANDONED_0 ((STATUS_ABANDONED_WAIT_0 ) + 0 ) | ||
18 | // WINAPI | ||
19 | DWORD WaitForMultipleObjects(DWORD count, const HANDLE *handles, BOOL wait_all, DWORD timeout); | ||
20 | */ | ||
21 | |||
22 | DWORD WINAPI WaitForMultiObj_Any_Infinite(DWORD count, const CHandle_WFMO *handles) | ||
23 | { | ||
24 | if (count < 1) | ||
25 | { | ||
26 | // abort(); | ||
27 | SetLastError(EINVAL); | ||
28 | return WAIT_FAILED; | ||
29 | } | ||
30 | |||
31 | CSynchro *synchro = handles[0]->_sync; | ||
32 | synchro->Enter(); | ||
33 | |||
34 | // #ifdef DEBUG_SYNCHRO | ||
35 | for (DWORD i = 1; i < count; i++) | ||
36 | { | ||
37 | if (synchro != handles[i]->_sync) | ||
38 | { | ||
39 | // abort(); | ||
40 | synchro->Leave(); | ||
41 | SetLastError(EINVAL); | ||
42 | return WAIT_FAILED; | ||
43 | } | ||
44 | } | ||
45 | // #endif | ||
46 | |||
47 | for (;;) | ||
48 | { | ||
49 | for (DWORD i = 0; i < count; i++) | ||
50 | { | ||
51 | if (handles[i]->IsSignaledAndUpdate()) | ||
52 | { | ||
53 | synchro->Leave(); | ||
54 | return WAIT_OBJECT_0 + i; | ||
55 | } | ||
56 | } | ||
57 | synchro->WaitCond(); | ||
58 | } | ||
59 | } | ||
60 | |||
61 | }} | ||
62 | |||
63 | #endif | ||