-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREAL.cpp
More file actions
45 lines (36 loc) · 947 Bytes
/
REAL.cpp
File metadata and controls
45 lines (36 loc) · 947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include "REAL.h"
VAR* REAL::clone(){ // cloner
VAR* temp =new REAL(name,val); // creating new variable
return temp;
}
REAL::REAL(string nm,double data){ // constructor
val=data;
name=nm;
type="REAL";
}
double REAL::get_val_real(){ // getting value
pthread_mutex_lock(&mutex);
while (lock == 1) {
pthread_cond_wait(&lockCondition, &mutex);
}
lock = 1;
double returnVal = val;
pthread_mutex_unlock(&mutex);
lock = 0;
pthread_cond_signal(&lockCondition);
return returnVal;
}
void REAL::ASSGN(double data){
pthread_mutex_lock(&mutex);
while (lock == 1) {
pthread_cond_wait(&lockCondition, &mutex);
}
lock = 1;
val = data;
lock = 0;
pthread_mutex_unlock(&mutex);
pthread_cond_signal(&lockCondition);
}
REAL::operator double() const { return val; } // operator overloading double
//virtual auto getValue()->double{return get_val_real();}
REAL::~REAL(){}