summaryrefslogtreecommitdiffstats
path: root/WebServer/cEvents.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-01-29 20:28:19 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-01-29 20:28:19 +0100
commit89afb970d88e3efa8ddb2f1eafff10cd6525f2b7 (patch)
tree206b3ba15c0fc87b3bf9ad7371f73887280945c4 /WebServer/cEvents.cpp
parentVC2008 compilation with new lua webplugin (diff)
downloadcuberite-89afb970d88e3efa8ddb2f1eafff10cd6525f2b7.tar
cuberite-89afb970d88e3efa8ddb2f1eafff10cd6525f2b7.tar.gz
cuberite-89afb970d88e3efa8ddb2f1eafff10cd6525f2b7.tar.bz2
cuberite-89afb970d88e3efa8ddb2f1eafff10cd6525f2b7.tar.lz
cuberite-89afb970d88e3efa8ddb2f1eafff10cd6525f2b7.tar.xz
cuberite-89afb970d88e3efa8ddb2f1eafff10cd6525f2b7.tar.zst
cuberite-89afb970d88e3efa8ddb2f1eafff10cd6525f2b7.zip
Diffstat (limited to '')
-rw-r--r--WebServer/cEvents.cpp (renamed from WebServer/cEvent.cpp)55
1 files changed, 34 insertions, 21 deletions
diff --git a/WebServer/cEvent.cpp b/WebServer/cEvents.cpp
index 289131568..4c9fa8775 100644
--- a/WebServer/cEvent.cpp
+++ b/WebServer/cEvents.cpp
@@ -1,16 +1,13 @@
-#include "cEvent.h"
-#include "../source/cMCLogger.h"
-#ifdef _WIN32
-#include <Windows.h>
-#else
-#include <semaphore.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <stdio.h> // sprintf()
-#endif
+#include "Globals.h" // NOTE: MSVC stupidness requires this to be the same across all modules
+
+#include "cEvents.h"
+
+
-cEvent::cEvent( unsigned int a_NumEvents /* = 1 */ )
+
+
+cEvents::cEvents( unsigned int a_NumEvents /* = 1 */ )
: m_NumEvents( a_NumEvents )
#ifndef _WIN32
, m_bNamed( false )
@@ -34,24 +31,28 @@ cEvent::cEvent( unsigned int a_NumEvents /* = 1 */ )
if( sem_init( HandlePtr, 0, 0 ) )
{
- LOG("WARNING cEvent: Could not create unnamed semaphore, fallback to named.");
+ LOG("WARNING cEvents: Could not create unnamed semaphore, fallback to named.");
m_bNamed = true;
delete HandlePtr; // named semaphores return their own address
char c_Str[32];
- sprintf( c_Str, "cEvent%p", &HandlePtr );
+ sprintf( c_Str, "cEvents%p", &HandlePtr );
HandlePtr = sem_open( c_Str, O_CREAT, 777, 0 );
if( HandlePtr == SEM_FAILED )
LOG("ERROR: Could not create Event. (%i)", errno);
else
if( sem_unlink( c_Str ) != 0 )
- LOG("ERROR: Could not unlink cEvent. (%i)", errno);
+ LOG("ERROR: Could not unlink cEvents. (%i)", errno);
}
}
#endif
}
-cEvent::~cEvent()
+
+
+
+
+cEvents::~cEvents()
{
#ifdef _WIN32
for( unsigned int i = 0; i < m_NumEvents; i++ )
@@ -66,12 +67,12 @@ cEvent::~cEvent()
{
sem_t* & HandlePtr = ((sem_t**)m_Handle)[i];
char c_Str[32];
- sprintf( c_Str, "cEvent%p", &HandlePtr );
+ sprintf( c_Str, "cEvents%p", &HandlePtr );
// LOG("Closing event: %s", c_Str );
// LOG("Sem ptr: %p", HandlePtr );
if( sem_close( HandlePtr ) != 0 )
{
- LOG("ERROR: Could not close cEvent. (%i)", errno);
+ LOG("ERROR: Could not close cEvents. (%i)", errno);
}
}
else
@@ -84,7 +85,11 @@ cEvent::~cEvent()
#endif
}
-void cEvent::Wait()
+
+
+
+
+void cEvents::Wait()
{
#ifdef _WIN32
WaitForMultipleObjects( m_NumEvents, (HANDLE*)m_Handle, true, INFINITE );
@@ -93,20 +98,28 @@ void cEvent::Wait()
{
if( sem_wait( ((sem_t**)m_Handle)[i] ) != 0 )
{
- LOG("ERROR: Could not wait for cEvent. (%i)", errno);
+ LOG("ERROR: Could not wait for cEvents. (%i)", errno);
}
}
#endif
}
-void cEvent::Set(unsigned int a_EventNum /* = 0 */)
+
+
+
+
+void cEvents::Set(unsigned int a_EventNum /* = 0 */)
{
#ifdef _WIN32
SetEvent( ((HANDLE*)m_Handle)[a_EventNum] );
#else
if( sem_post( ((sem_t**)m_Handle)[a_EventNum] ) != 0 )
{
- LOG("ERROR: Could not set cEvent. (%i)", errno);
+ LOG("ERROR: Could not set cEvents. (%i)", errno);
}
#endif
}
+
+
+
+