1 #include "ArbitrationRound.h"
3 #include "CommitPart.h"
5 ArbitrationRound::ArbitrationRound(Commit *_commit, Hashset<Abort *> *_abortsBefore) :
6 abortsBefore(_abortsBefore),
7 parts(new MyVector<Entry *>()),
11 didGenerateParts(false) {
14 commit->createCommitParts();
15 currentSize += commit->getNumberOfParts();
18 currentSize += abortsBefore->size();
21 ArbitrationRound::~ArbitrationRound() {
23 uint partsSize = parts->size();
24 for (uint i = 0; i < partsSize; i++) {
25 Entry * part = parts->get(i);
33 void ArbitrationRound::generateParts() {
34 if (didGenerateParts) {
37 uint partsSize = parts->size();
38 for (uint i = 0; i < partsSize; i++) {
39 Entry * part = parts->get(i);
43 SetIterator<Abort *, Abort *> *abit = abortsBefore->iterator();
44 while (abit->hasNext())
45 parts->add((Entry *)abit->next());
48 MyVector<CommitPart *> *cParts = commit->getParts();
49 uint cPartsSize = cParts->size();
50 for (uint i = 0; i < cPartsSize; i++) {
51 CommitPart * part = cParts->get(i);
53 parts->add((Entry *)part);
58 MyVector<Entry *> *ArbitrationRound::getParts() {
62 void ArbitrationRound::removeParts(MyVector<Entry *> *removeParts) {
63 uint size = removeParts->size();
64 for(uint i=0; i < size; i++) {
65 Entry * e = removeParts->get(i);
73 bool ArbitrationRound::isDoneSending() {
74 if ((commit == NULL) && abortsBefore->isEmpty()) {
77 return parts->isEmpty();
80 Commit *ArbitrationRound::getCommit() {
84 void ArbitrationRound::setCommit(Commit *_commit) {
86 currentSize -= commit->getNumberOfParts();
91 currentSize += commit->getNumberOfParts();
95 void ArbitrationRound::addAbort(Abort *abort) {
96 abortsBefore->add(abort);
100 void ArbitrationRound::addAborts(Hashset<Abort *> *aborts) {
101 abortsBefore->addAll(aborts);
102 currentSize += aborts->size();
105 Hashset<Abort *> *ArbitrationRound::getAborts() {
109 int ArbitrationRound::getAbortsCount() {
110 return abortsBefore->size();
113 int ArbitrationRound::getCurrentSize() {
117 bool ArbitrationRound::isFull() {
118 return currentSize >= ArbitrationRound_MAX_PARTS;
121 bool ArbitrationRound::getDidSendPart() {