From f4c0efae8d41575ef4e9e7b2d50697cfe99038b5 Mon Sep 17 00:00:00 2001 From: Jim Carroll Date: Sun, 19 Jun 2011 22:30:53 -0400 Subject: Removed all WaitForSingleObject and WaitForMultipleObjects calls and replaced them with the latest CEvent calls. --- lib/UnrarXLib/extract.cpp | 18 +++++++++--------- lib/UnrarXLib/rdwrfn.cpp | 14 +++++++------- lib/UnrarXLib/rdwrfn.hpp | 11 ++++++----- lib/UnrarXLib/unpack.cpp | 6 +++--- lib/UnrarXLib/unpack15.cpp | 2 +- 5 files changed, 26 insertions(+), 25 deletions(-) (limited to 'lib/UnrarXLib') diff --git a/lib/UnrarXLib/extract.cpp b/lib/UnrarXLib/extract.cpp index 17e5052d6a..74a795b3cd 100644 --- a/lib/UnrarXLib/extract.cpp +++ b/lib/UnrarXLib/extract.cpp @@ -751,7 +751,7 @@ bool CmdExtract::ExtractCurrentFile(CommandData *Cmd,Archive &Arc,int HeaderSize } if (DataIO.UnpackToMemorySize > -1) - if (WaitForSingleObject(DataIO.hQuit,1) == WAIT_OBJECT_0) + if (DataIO.hQuit->WaitMSec(1)) { return false; } @@ -841,14 +841,14 @@ void CmdExtract::UnstoreFile(ComprDataIO &DataIO,Int64 DestUnpSize) { while (1) { - if (WaitForSingleObject(DataIO.hQuit,1) == WAIT_OBJECT_0) + if (DataIO.hQuit->WaitMSec(1)) { return; } int Code=DataIO.UnpRead(&Buffer[0],Buffer.Size()); if (DataIO.UnpackToMemorySize > -1 && !DataIO.NextVolumeMissing) { - if (WaitForSingleObject(DataIO.hSeek,1) == WAIT_OBJECT_0) + if (DataIO.hSeek->WaitMSec(1)) continue; } if (Code > 0) @@ -861,14 +861,14 @@ void CmdExtract::UnstoreFile(ComprDataIO &DataIO,Int64 DestUnpSize) else { if (DataIO.NextVolumeMissing) - SetEvent(DataIO.hSeekDone); + DataIO.hSeekDone->Set(); else - if (WaitForSingleObject(DataIO.hSeek,1) == WAIT_OBJECT_0) + if (DataIO.hSeek->WaitMSec(1)) continue; - ResetEvent(DataIO.hBufferFilled); - SetEvent(DataIO.hBufferEmpty); - while (WaitForSingleObject(DataIO.hBufferFilled,1) != WAIT_OBJECT_0) - if (WaitForSingleObject(DataIO.hQuit,1) == WAIT_OBJECT_0) + DataIO.hBufferFilled->Reset(); + DataIO.hBufferEmpty->Set(); + while (DataIO.hBufferFilled->WaitMSec(1)) + if (DataIO.hQuit->WaitMSec(1)) return; } } diff --git a/lib/UnrarXLib/rdwrfn.cpp b/lib/UnrarXLib/rdwrfn.cpp index dd87a07b36..6d1c055f1c 100644 --- a/lib/UnrarXLib/rdwrfn.cpp +++ b/lib/UnrarXLib/rdwrfn.cpp @@ -63,7 +63,7 @@ int ComprDataIO::UnpRead(byte *Addr,uint Count) return(-1); } if (UnpackToMemory) - if (WaitForSingleObject(hSeek,1) == WAIT_OBJECT_0) // we are seeking + if (hSeek->WaitMSec(1)) // we are seeking { if (m_iSeekTo > CurUnpStart+SrcArc->NewLhd.FullPackSize) // need to seek outside this block { @@ -113,8 +113,8 @@ int ComprDataIO::UnpRead(byte *Addr,uint Count) CurUnpRead = CurUnpStart + iSeekTo - iStartOfFile; CurUnpWrite = SrcFile->Tell() - iStartOfFile + CurUnpStart; - ResetEvent(hSeek); - SetEvent(hSeekDone); + hSeek->Reset(); + hSeekDone->Set(); } } if (bRead) @@ -210,13 +210,13 @@ void ComprDataIO::UnpWrite(byte *Addr,uint Count) { while(UnpackToMemorySize < (int)Count) { - SetEvent(hBufferEmpty); - while( WaitForSingleObject(hBufferFilled,1) != WAIT_OBJECT_0) - if (WaitForSingleObject(hQuit,1) == WAIT_OBJECT_0) + hBufferEmpty->Set(); + while( hBufferFilled->WaitMSec(1)) + if (hQuit->WaitMSec(1)) return; } - if (WaitForSingleObject(hSeek,1) != WAIT_OBJECT_0) // we are seeking + if (hSeek->WaitMSec(1)) // we are seeking { memcpy(UnpackToMemoryAddr,Addr,Count); UnpackToMemoryAddr+=Count; diff --git a/lib/UnrarXLib/rdwrfn.hpp b/lib/UnrarXLib/rdwrfn.hpp index 95111ca316..69d7f5906e 100644 --- a/lib/UnrarXLib/rdwrfn.hpp +++ b/lib/UnrarXLib/rdwrfn.hpp @@ -5,6 +5,7 @@ class CmdAdd; class Unpack; #include "system.h" +#include "threads/Event.h" class CGUIDialogProgress; @@ -84,11 +85,11 @@ class ComprDataIO int UnpackToMemorySize; // added stuff - HANDLE hBufferFilled; - HANDLE hBufferEmpty; - HANDLE hSeek; - HANDLE hSeekDone; - HANDLE hQuit; + CEvent* hBufferFilled; + CEvent* hBufferEmpty; + CEvent* hSeek; + CEvent* hSeekDone; + CEvent* hQuit; CGUIDialogProgress* m_pDlgProgress; bool bQuit; Int64 m_iSeekTo; diff --git a/lib/UnrarXLib/unpack.cpp b/lib/UnrarXLib/unpack.cpp index 1361128c44..113260b121 100644 --- a/lib/UnrarXLib/unpack.cpp +++ b/lib/UnrarXLib/unpack.cpp @@ -410,9 +410,9 @@ void Unpack::Unpack29(bool Solid) if (UnpIO->UnpackToMemorySize > -1) { - SetEvent(UnpIO->hBufferEmpty); - while (WaitForSingleObject(UnpIO->hBufferFilled,1) != WAIT_OBJECT_0) - if (WaitForSingleObject(UnpIO->hQuit,1) == WAIT_OBJECT_0) + UnpIO->hBufferEmpty->Set(); + while (UnpIO->hBufferFilled->WaitMSec(1)) + if (UnpIO->hQuit->WaitMSec(1)) return; } } diff --git a/lib/UnrarXLib/unpack15.cpp b/lib/UnrarXLib/unpack15.cpp index fa69b3eade..e1b5f106d7 100644 --- a/lib/UnrarXLib/unpack15.cpp +++ b/lib/UnrarXLib/unpack15.cpp @@ -67,7 +67,7 @@ void Unpack::Unpack15(bool Solid) while (DestUnpSize>=0) { - if (WaitForSingleObject(UnpIO->hQuit,1) == WAIT_OBJECT_0) + if (UnpIO->hQuit->WaitMSec(1)) return; UnpPtr&=MAXWINMASK; -- cgit v1.2.3