-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTransaction.cpp
More file actions
39 lines (28 loc) · 848 Bytes
/
Transaction.cpp
File metadata and controls
39 lines (28 loc) · 848 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
//
// Created by supreets51 on 15/10/19.
//
#include "Transaction.h"
Transaction::Transaction(int i, int m_): id(i), m(m_), status('s') {
writeSet = std::set<int>();
readSet = std::set<int>();
// initialize
// Initially stores -1 for each item.
local_write_store = std::vector<int>();
for(int j=0; j<m; j++) local_write_store.push_back(-1);
}
char Transaction::getStatus() const {
return this->status;
}
// Just inserts the DataItem index into the readSet. Do rest of the stuff inside the scheduler's read function
int Transaction::read(const int data_item) {
readSet.insert(data_item);
return 0;
}
int Transaction::write(const int data_item, int value) {
local_write_store[data_item] = value;
writeSet.insert(data_item);
return 0;
}
void Transaction::setStatus(char a) {
status = a;
}