+#pragma once
/*
* This file is part of the libCEC(R) library.
*
* http://www.pulse-eight.net/
*/
-#include "threads.h"
-#include "timeutils.h"
-#include "os-dependent.h"
-
-using namespace CEC;
-
-CLockObject::CLockObject(IMutex *mutex, bool bTryLock /* = false */) :
- m_mutex(mutex)
-{
- if (m_mutex)
- m_bLocked = bTryLock ? m_mutex->TryLock() : m_mutex->Lock();
-}
-
-CLockObject::~CLockObject(void)
-{
- Leave();
- m_mutex = NULL;
-}
-
-void CLockObject::Leave(void)
-{
- if (m_mutex && m_bLocked)
- {
- m_bLocked = false;
- m_mutex->Unlock();
- }
-}
-
-void CLockObject::Lock(void)
-{
- if (m_mutex)
- m_bLocked = m_mutex->Lock();
-}
+#if defined(_WIN32) || defined(_WIN64)
+#ifndef __WINDOWS__
+#define __WINDOWS__
+#endif
+#include "windows/os-types.h"
+#include "windows/os-threads.h"
+#else
+#include "posix/os-types.h"
+#include "posix/os-threads.h"
+#endif
-void ICondition::Sleep(uint32_t iTimeout)
-{
- CCondition w;
- CMutex m;
- CLockObject lock(&m);
- w.Wait(&m, iTimeout);
-}
-
-IThread::IThread(void) :
- m_bStop(false),
- m_bRunning(false)
-{
- m_threadCondition = new CCondition();
- m_threadMutex = new CMutex();
-}
-
-IThread::~IThread(void)
-{
- StopThread();
- delete m_threadCondition;
- delete m_threadMutex;
-}
-
-bool IThread::StopThread(bool bWaitForExit /* = true */)
-{
- m_bStop = true;
- m_threadCondition->Broadcast();
- bWaitForExit = true;
-
- return false;
-}
-
-bool IThread::Sleep(uint32_t iTimeout)
-{
- CLockObject lock(m_threadMutex);
- return m_bStop ? false : m_threadCondition->Wait(m_threadMutex, iTimeout);
-}
+#include "timeutils.h"
+#include "threads/threads.h"
+#include "buffer.h"
+#include "StdString.h"