summaryrefslogtreecommitdiffstats
path: root/private/unimodem/new/mic/sync.h
diff options
context:
space:
mode:
authorAdam <you@example.com>2020-05-17 05:51:50 +0200
committerAdam <you@example.com>2020-05-17 05:51:50 +0200
commite611b132f9b8abe35b362e5870b74bce94a1e58e (patch)
treea5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/unimodem/new/mic/sync.h
downloadNT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip
Diffstat (limited to 'private/unimodem/new/mic/sync.h')
-rw-r--r--private/unimodem/new/mic/sync.h148
1 files changed, 148 insertions, 0 deletions
diff --git a/private/unimodem/new/mic/sync.h b/private/unimodem/new/mic/sync.h
new file mode 100644
index 000000000..95f9bbe48
--- /dev/null
+++ b/private/unimodem/new/mic/sync.h
@@ -0,0 +1,148 @@
+//
+// Copyright (c) 1996 Microsoft Corporation
+//
+//
+// SYNC.H -- Header for Classes:
+// CSync
+//
+// History:
+// 05/21/96 JosephJ Created
+//
+//
+#ifndef _SYNC_H_
+#define _SYNC_H_
+
+
+///////////////////////////////////////////////////////////////////////////
+// CLASS CSync
+///////////////////////////////////////////////////////////////////////////
+
+// Controls access to its parent object. Includes a critical section, and
+// (TODO) mechanism for waiting until all threads have finished using
+// the parent object.
+
+// Sample session (pObj is a ptr to a hypothetical parent, which implements
+// methods Load, Unload, OpenSession, CloseSession using the member CSymc
+// object):
+// pObj->Load("mdmusr.inf");
+// hSession = pObj->OpenSession();
+// ... do stuff ...
+// pObj->CloseSession(hSession);
+// hSync = pObj->Unload();
+// if (hSync) WaitForSingleObject(hSync, INFINITE);
+// CloseHandle(hSync);
+
+class CSync
+{
+
+public:
+
+ CSync(void) {InitializeCriticalSection(&m_crit);}
+
+ ~CSync()
+ {
+ EnterCriticalSection(&m_crit);
+ DeleteCriticalSection(&m_crit);
+ }
+
+ //-------------- EnterCrit ------------------
+ // Claim our critical section
+ void EnterCrit(void) const
+ {
+ EnterCriticalSection((CRITICAL_SECTION *)&m_crit);
+ }
+
+ //-------------- LeaveCrit ------------------
+ // Release our critical section
+ void LeaveCrit(void) const
+ {
+ LeaveCriticalSection((CRITICAL_SECTION *)&m_crit);
+ }
+
+#if (TODO)
+
+ BOOL BeginLoad(void)
+ {
+ }
+
+ void EndLoad(void)
+ {
+ EnterCrit();
+ ASSERT (m_eState == CSYNC_LOADING);
+ m_eState = CSYNC_LOADED;
+ LeaveCrit();
+ }
+
+ HANDLE BeginUnload(void)
+ {
+ HANDLE h=NULL;
+ EnterCrit();
+ if (m_eState == CSYNC_LOADED)
+ {
+ m_eState = CSYNC_UNLOADING;
+ }
+ else
+ {
+ fRet = FALSE;
+ }
+ LeaveCrit();
+
+ return fRet;
+ }
+
+ void EndUnload(void);
+
+ HSESSION BeginSession(void)
+ {
+ HSESSION hRet = 1;
+ EnterCrit();
+ if (m_eState==SYNC_LOADED)
+ {
+ m_uRefCount++;
+ }
+ else
+ {
+ hRet = 0;
+ }
+ LeaveCrit();
+
+ return hRet;
+ }
+
+ void EndSession(HSESSION hSession)
+ {
+ SLINST *pEventList=NULL;
+ EnterCrit();
+ ASSERT(hSession==1 && m_uRefCount);
+ m_uRefCount--;
+ if (m_eState==SYNC_UNLOADING && m_pEventList)
+ {
+ pEventList = m_pEventList;
+ m_pEventList=NULL;
+ }
+ LeaveCrit();
+
+ mfn_SignalAndFree(m_pEventList);
+ }
+
+ BOOL AddContext(HSESSION hS)
+ {
+ return FALSE;
+ }
+#endif // TODO
+
+private:
+
+ CRITICAL_SECTION m_crit;
+
+#if (TODO)
+ UINT m_uRefCount;
+ enum {CSYNC_UNLOADED, CSYNC_LOADING, CSYNC_UNLOADING, CSYNC_UNLOADED}
+ m_eState;
+ SLIST* pUnloadEventList;
+#endif // TODO
+
+};
+
+
+#endif // _SYNC_H_