submitting patch from enterprise version
[csql.git] / include / Mutex.h
blobcf2833f868c54eef7dddd79d31ea14d2446f4c50
1 /***************************************************************************
2 * *
3 * Copyright (C) Lakshya Solutions Ltd. All rights reserved. *
4 * *
5 ***************************************************************************/
7 #ifndef MUTEX_H
8 #define MUTEX_H
9 #include<os.h>
10 typedef unsigned int Lock;
11 class Mutex
13 int noOfRead;
14 #if defined(sparc) || defined(i686) || defined (x86_64)
15 Lock lock;
16 #else
17 pthread_mutex_t mutex_;
18 #endif
19 public:
20 char name[20];
21 Mutex();
22 int init();
23 int init(char *name);
24 int tryLock(int tries=0, int waitmsecs=0,bool share=false);
25 int getLock(int procSlot, bool procAccount=true,bool share=false);
26 int releaseLock(int procSlot, bool procAccount=true,bool share=false);
27 int destroy();
28 int recoverMutex();
29 static int CASL(long *ptr, long oldVal, long newVal);
30 static int CAS(int *ptr, int oldVal, int newVal);
33 #endif