source: trunk/src/kernel32/vmutex.cpp@ 46

Last change on this file since 46 was 46, checked in by sandervl, 26 years ago

* empty log message *

File size: 1.6 KB
Line 
1/*
2 *
3 * Project Odin Software License can be found in LICENSE.TXT
4 *
5 */
6/*
7 * Mutex class
8 *
9 * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
10 *
11 */
12#define INCL_DOSSEMAPHORES
13#include <os2.h>
14#include <vmutex.h>
15#include <win32type.h>
16#include <misc.h>
17
18/******************************************************************************/
19/******************************************************************************/
20_Export VMutex::VMutex() : waiting(0)
21{
22 APIRET rc;
23
24 rc = DosCreateMutexSem(NULL, &sem_handle, 0, FALSE);
25 if(rc != 0) {
26 dprintf(("Error creating mutex %X\n", rc));
27 sem_handle = 0;
28 }
29}
30/******************************************************************************/
31/******************************************************************************/
32_Export VMutex::~VMutex()
33{
34 int i;
35
36 if(sem_handle) {
37 for(i=0;i<waiting;i++) {
38 DosReleaseMutexSem(sem_handle);
39 }
40 DosCloseMutexSem(sem_handle);
41 }
42}
43/******************************************************************************/
44/******************************************************************************/
45void _Export VMutex::enter(ULONG timeout)
46{
47 if(sem_handle) {
48 waiting++;
49 DosRequestMutexSem(sem_handle, timeout);
50 waiting--;
51 }
52}
53/******************************************************************************/
54/******************************************************************************/
55void _Export VMutex::leave()
56{
57 DosReleaseMutexSem(sem_handle);
58}
59/******************************************************************************/
60/******************************************************************************/
61
Note: See TracBrowser for help on using the repository browser.