00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "mxsemaphore.h"
00017
00018
00019
00020
00021 namespace mx
00022 {
00023
00024 mxSem::mxSem(unsigned int value)
00025 {
00026
00027 sem = SDL_CreateSemaphore(value);
00028
00029
00030 }
00031
00032 mxSem::~mxSem()
00033 {
00034
00035 if(sem != 0)
00036 SDL_DestroySemaphore(sem);
00037
00038 }
00039
00040 const unsigned int mxSem::currentValue() const
00041 {
00042
00043 return SDL_SemValue(sem);
00044
00045 }
00046
00047 int mxSem::wait()
00048 {
00049
00050 return SDL_SemWait(sem);
00051
00052 }
00053
00054 int mxSem::tryWait()
00055 {
00056
00057 return SDL_SemTryWait(sem);
00058
00059 }
00060
00061 int mxSem::waitTimeout(unsigned int interval)
00062 {
00063
00064 return SDL_SemWaitTimeout(sem, interval);
00065
00066 }
00067
00068 int mxSem::post()
00069 {
00070 return SDL_SemPost(sem);
00071 }
00072 }
00073
00074