>>>>>>>>>> CSplit: Version 2.2 >>>>>>>>>>
>>>>>>>>>> CSplit: Begin part 4/6 >>>>>>>>>>
}
bool MutexSem::Release()
{
return NO_ERROR == DosReleaseMutexSem(m_hmtxProtFile);
}
bool MutexSem::Close()
{
return NO_ERROR == DosCloseMutexSem(m_hmtxProtFile);
}
bool MutexSem::IsClaimed() const
{
// First we gotta query the semaphore.
PID pid;
TID tid;
ULONG ulCount;
DosQueryMutexSem(m_hmtxProtFile, &pid, &tid, &ulCount);
// quick check: no one has claimed it:
if (0 == ulCount)
{
return false;
}
// otherwise, we must find out our process and thread ids.
PPIB ppib;
PTIB ptib;
APIRET ulrcDGIB = DosGetInfoBlocks(&ptib, &ppib);
if (NO_ERROR != ulrcDGIB)
{
return false; // don't know what else to say...
}
// It is claimed only if both our process and thread match.
return pid == ppib->pib_ulpid && tid == ptib->tib_ptib2->tib2_ultid;
}
MutexSem::operator bool() const
{
return m_hmtxProtFile != 0;
}
>>>>>>>>>> CSplit: End file sem32.cc >>>>>>>>>>
>>>>>>>>>> CSplit: Begin file sem32.h >>>>>>>>>>
//
// Class for implementing 16 & 32-bit semaphores
//
#ifndef __SEMAPHORE__HPP
#define __SEMAPHORE__HPP
#include "semaphore.h"
#include
class MutexSem : public Semaphore
{
private:
HMTX m_hmtxProtFile;
public:
MutexSem();
virtual ~MutexSem();
virtual Error Create(const String& strSemName);
virtual Error MutexSem::Create();
virtual Error Claim(unsigned long ulTimeOut = \
\
SEM_INDEFINITE_WAIT);
virtual bool Release();
virtual bool Close();
virtual bool IsClaimed() const;
virtual operator bool() const;
};
#endif // __SEMAPHORE__HPP
>>>>>>>>>> CSplit: End file sem32.h >>>>>>>>>>
>>>>>>>>>> CSplit: Begin file semaphore.h >>>>>>>>>>
//
// Abstraction of semaphore operations.
//
#ifndef __SEMAPHORE_H
>>>>>>>>>> CSplit: End part 4/6 crc: 0364 >>>>>>>>>>
--- FastEcho 1.46
---------------
* Origin: House of Fire BBS - Toronto - (416)601-0085 - v.34 (1:250/536)
|