Documentation for Synchronisation primitives

Former-commit-id: 39f86b2f9cd1f44a6b8e52101458f090183707e4
This commit is contained in:
Gawaboumga
2016-02-21 14:36:03 +01:00
parent 07547bdd9f
commit fd627c671f
6 changed files with 144 additions and 8 deletions

View File

@@ -18,8 +18,8 @@ namespace Nz
void FileImpl::Close()
{
if (m_fileDescriptor != -1)
close(m_fileDescriptor);
if (m_fileDescriptor != -1)
close(m_fileDescriptor);
}
bool FileImpl::EndOfFile() const
@@ -62,16 +62,16 @@ namespace Nz
flags = O_CREAT | O_WRONLY;
else
return false;
if (mode & OpenMode_Append)
flags |= O_APPEND;
if (mode & OpenMode_Truncate)
flags |= O_TRUNC;
///TODO: lock
// if ((mode & OpenMode_Lock) == 0)
// shareMode |= FILE_SHARE_WRITE;
///TODO: lock
//if ((mode & OpenMode_Lock) == 0)
// shareMode |= FILE_SHARE_WRITE;
m_fileDescriptor = open64(filePath.GetConstBuffer(), flags, permissions);
return m_fileDescriptor != -1;

View File

@@ -13,7 +13,7 @@ namespace Nz
{
SemaphoreImpl::SemaphoreImpl(unsigned int count)
{
if(sem_init(&m_semaphore, 0, count) != 0)
if (sem_init(&m_semaphore, 0, count) != 0)
NazaraError("Failed to create semaphore: " + Error::GetLastSystemError());
}
@@ -68,7 +68,7 @@ namespace Nz
return true;
#else
return sem_timedwait(&m_semaphore, &ti) != 0;
return sem_timedwait(&m_semaphore, &ti) != 0;
#endif
}
}