added:
* win32_slim.h: includes the minimal version of windows.h modified: * cthread: added lock_t c++ class * os: added getUserName() * socket: modified socket_len_t to sk_len_t to better follow naming convetions in file * str: added operator std::string() to str_t
This commit is contained in:
parent
7fdc8b5301
commit
bce93361b1
16 changed files with 187 additions and 70 deletions
25
cthreads.h
25
cthreads.h
|
|
@ -37,6 +37,31 @@ bool mtxLock(cmutex_t ctx);
|
|||
bool mtxTryLock(cmutex_t ctx);
|
||||
bool mtxUnlock(cmutex_t ctx);
|
||||
|
||||
#ifdef __cplusplus
|
||||
// small c++ class to make mutexes easier to use
|
||||
struct lock_t {
|
||||
inline lock_t(cmutex_t mutex)
|
||||
: mutex(mutex) {
|
||||
if (mtxValid(mutex)) {
|
||||
mtxLock(mutex);
|
||||
}
|
||||
}
|
||||
|
||||
inline ~lock_t() {
|
||||
unlock();
|
||||
}
|
||||
|
||||
inline void unlock() {
|
||||
if (mtxValid(mutex)) {
|
||||
mtxUnlock(mutex);
|
||||
}
|
||||
mutex = 0;
|
||||
}
|
||||
|
||||
cmutex_t mutex;
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // extern "C"
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue