Changeset 655 for trunk/src


Ignore:
Timestamp:
Aug 24, 1999, 11:20:30 AM (26 years ago)
Author:
sandervl
Message:

One mutex per object type + mutex protection in win32 class

Location:
trunk/src/user32/new
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/new/gen_object.cpp

    r308 r655  
    1 /* $Id: gen_object.cpp,v 1.2 1999-07-15 12:01:31 sandervl Exp $ */
     1/* $Id: gen_object.cpp,v 1.3 1999-08-24 09:20:30 sandervl Exp $ */
    22/*
    33 * Generic Object Class for OS/2
     
    1313#include <gen_object.h>
    1414#include <misc.h>
     15#include <vmutex.h>
    1516
    16 HMTX genMutexSem = 0;
     17VMutex genMutex[OBJTYPE_MAX];
    1718
    1819//******************************************************************************
     
    2021GenericObject::GenericObject(GenericObject **head, DWORD objType)
    2122{
    22  APIRET rc;
    23 
    2423  this->objType = objType;
    2524  this->head    = head;
    2625  this->next    = NULL;
    2726
    28   if(genMutexSem == 0) {
    29         rc = DosCreateMutexSem(NULL, &genMutexSem, 0, FALSE);
    30         if(rc) {
    31                 dprintf(("GenericObject ctor: DosCreateMutexSem returned %d", rc));
    32                 DebugInt3();
    33                 exit(1);
    34         }
    35   }
    36   //insert in linked list
    37   rc = DosRequestMutexSem(genMutexSem, SEM_INDEFINITE_WAIT);
    38   if(rc) {
    39         dprintf(("GenericObject ctor: DosRequestMutexSem returned %d", rc));
    40         DebugInt3();
    41   }
     27  genMutex[objType].enter();
    4228  if(*head == NULL) {
    4329        *head = this;   
     
    5137        cur->next = this;
    5238  }
    53   DosReleaseMutexSem(genMutexSem);
     39  genMutex[objType].leave();
    5440}
    5541//******************************************************************************
     
    5743GenericObject::~GenericObject()
    5844{
    59  APIRET rc;
    60 
    6145  //remove from linked list
    62   rc = DosRequestMutexSem(genMutexSem, SEM_INDEFINITE_WAIT);
    63   if(rc) {
    64         dprintf(("GenericObject dtor: DosRequestMutexSem returned %d", rc));
    65         DebugInt3();
    66   }
     46  genMutex[objType].enter();
    6747  if(*head == this) {
    6848        *head = next;   
     
    8060        cur->next = next;
    8161  }
    82   DosReleaseMutexSem(genMutexSem);
     62  genMutex[objType].leave();
    8363}
    8464//******************************************************************************
    8565//******************************************************************************
     66void GenericObject::enterMutex()
     67{
     68  genMutex[objType].enter();
     69}
     70//******************************************************************************
     71//******************************************************************************
     72void GenericObject::leaveMutex()
     73{
     74  genMutex[objType].leave();
     75}
     76//******************************************************************************
     77//******************************************************************************
     78void GenericObject::enterMutex(DWORD objType)
     79{
     80  genMutex[objType].enter();
     81}
     82//******************************************************************************
     83//******************************************************************************
     84void GenericObject::leaveMutex(DWORD objType)
     85{
     86  genMutex[objType].leave();
     87}
     88//******************************************************************************
     89//******************************************************************************
  • trunk/src/user32/new/gen_object.h

    r300 r655  
    1 /* $Id: gen_object.h,v 1.1 1999-07-14 08:35:34 sandervl Exp $ */
     1/* $Id: gen_object.h,v 1.2 1999-08-24 09:20:30 sandervl Exp $ */
    22/*
    33 * Generic Object Class for OS/2
     
    1616#define OBJTYPE_CURSOR          5
    1717#define OBJTYPE_MENU            6
     18
     19#define OBJTYPE_MAX             7
    1820//......
    1921
     
    3032GenericObject *GetNext()        { return next;  };
    3133
    32          
     34         void  enterMutex();
     35         void  leaveMutex();
     36
     37static   void  enterMutex(DWORD objType);
     38static   void  leaveMutex(DWORD objType);
     39
    3340private:
    3441
  • trunk/src/user32/new/win32class.cpp

    r606 r655  
    1 /* $Id: win32class.cpp,v 1.6 1999-08-21 12:53:28 sandervl Exp $ */
     1/* $Id: win32class.cpp,v 1.7 1999-08-24 09:20:30 sandervl Exp $ */
    22/*
    33 * Win32 Window Class Managment Code for OS/2
     
    120120Win32WndClass *Win32WndClass::FindClass(HINSTANCE hInstance, LPSTR id)
    121121{
     122  enterMutex(OBJTYPE_CLASS);
     123
    122124  Win32WndClass *wndclass = (Win32WndClass *)wndclasses;
    123125
    124   if(wndclass == NULL)  return(NULL);
     126  if(wndclass == NULL) {
     127        leaveMutex(OBJTYPE_CLASS);
     128        return(NULL);
     129  }
    125130
    126131  if(HIWORD(id) != 0) {
    127132//CB: read comment below!
    128133        if(stricmp(wndclass->classNameA, id) == 0 && wndclass->hInstance == hInstance) {
     134                leaveMutex(OBJTYPE_CLASS);
    129135                return(wndclass);
    130136        }
     
    133139                while(wndclass != NULL) {
    134140                        if(stricmp(wndclass->classNameA, id) == 0 && wndclass->hInstance == hInstance) {
     141                                leaveMutex(OBJTYPE_CLASS);
    135142                                return(wndclass);
    136143                        }
     
    143150//CB: need more code to compare instance; convert 0 to exe module handle
    144151        if(wndclass->classAtom == (DWORD)id /*&& wndclass->hInstance == hInstance*/) {
     152                leaveMutex(OBJTYPE_CLASS);
    145153                return(wndclass);
    146154        }
     
    149157                while(wndclass != NULL) {
    150158                        if(wndclass->classAtom == (DWORD)id/* && wndclass->hInstance == hInstance*/) {
    151                                 return(wndclass);
     159                                leaveMutex(OBJTYPE_CLASS);
     160                                return(wndclass);
    152161                        }
    153162                        wndclass = (Win32WndClass *)wndclass->GetNext();
     
    155164        }
    156165  }
     166  leaveMutex(OBJTYPE_CLASS);
    157167  dprintf(("Class %X (inst %X) not found!", id, hInstance));
    158168  return(NULL);
Note: See TracChangeset for help on using the changeset viewer.