#include "EmuFileWrapper.h"
#include "filesystem/File.h"
-#include "threads/Mutex.h"
#include "threads/SingleLock.h"
CEmuFileWrapper g_emuFileWrapper;
object->used = true;
object->file_xbmc = pFile;
object->file_emu._file = (i + FILE_WRAPPER_OFFSET);
- object->file_lock = new CMutex();
+ object->file_lock = new CCriticalSection();
break;
}
}
{
if (m_files[i].used)
{
- m_files[i].file_lock->Wait();
+ m_files[i].file_lock->lock();
}
}
}
{
if (m_files[i].used)
{
- return m_files[i].file_lock->WaitMSec(0);
+ return m_files[i].file_lock->try_lock();
}
}
return false;
{
if (m_files[i].used)
{
- m_files[i].file_lock->Release();
+ m_files[i].file_lock->unlock();
}
}
}
#include "system.h"
#include "threads/CriticalSection.h"
-class CMutex;
-
#if defined(_LINUX) && !defined(__APPLE__) && !defined(__FreeBSD__)
#define _file _fileno
#endif
bool used;
FILE file_emu;
XFILE::CFile* file_xbmc;
- CMutex *file_lock;
+ CCriticalSection *file_lock;
int mode;
} EmuFileObject;
SRCS=Atomics.cpp \
Event.cpp \
- Mutex.cpp \
LockFree.cpp \
Semaphore.cpp \
Thread.cpp \
+++ /dev/null
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#include "Mutex.h"
-
-
-CMutex::CMutex()
-{
- m_hMutex = CreateMutex( NULL, FALSE, NULL);
-}
-
-CMutex::CMutex( char* pName )
-{
- m_hMutex = CreateMutex( NULL, FALSE, pName);
-}
-
-CMutex::~CMutex()
-{
- CloseHandle(m_hMutex);
- m_hMutex = NULL;
-}
-
-bool CMutex::Wait()
-{
- if (m_hMutex)
- if (WAIT_OBJECT_0 == WaitForSingleObject(m_hMutex, INFINITE))
- return true;
- return false;
-}
-
-void CMutex::Release()
-{
- if (m_hMutex)
- ReleaseMutex(m_hMutex);
-}
-
-CMutexWait::CMutexWait(CMutex& mutex)
- : m_mutex(mutex)
-{
- m_bLocked = m_mutex.Wait();
-}
-
-CMutexWait::~CMutexWait()
-{
- if (m_bLocked)
- m_mutex.Release();
-}
-
-
-HANDLE CMutex::GetHandle()
-{
- return m_hMutex;
-}
-
-bool CMutex::WaitMSec(unsigned int milliSeconds)
-{
- return m_hMutex && WaitForSingleObject(m_hMutex, milliSeconds) == WAIT_OBJECT_0;
-}
\ No newline at end of file
+++ /dev/null
-#pragma once
-
-/*
- * Copyright (C) 2005-2008 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-// CMutex - Wrapper for xbox Mutex API
-//
-// by Bobbin007 in 2003
-
-#include "system.h" // for HANDLE
-
-class CMutex
-{
-public:
- CMutex();
- CMutex( char* pName );
- virtual ~CMutex();
-
- HANDLE GetHandle();
-
- void Release();
-
- bool Wait();
- bool WaitMSec(unsigned int milliSeconds);
-
-protected:
- HANDLE m_hMutex;
-};
-
-class CMutexWait
-{
-public:
- CMutexWait(CMutex& mutex);
- virtual ~CMutexWait();
-private:
- CMutex& m_mutex;
- bool m_bLocked;
-};