1 #include "ArbitrationRound.h"
4 ArbitrationRound::ArbitrationRound(Commit *_commit, Hashset<Abort *> *_abortsBefore) :
5 abortsBefore(_abortsBefore),
6 parts(new Vector<Entry *>()),
10 didGenerateParts(false) {
13 commit->createCommitParts();
14 currentSize += commit->getNumberOfParts();
17 currentSize += abortsBefore->size();
21 void ArbitrationRound::generateParts() {
22 if (didGenerateParts) {
25 parts = new Vector<Entry *>((Vector<Entry *> *)abortsBefore);
27 parts->addAll(commit->getParts()->values());
31 Vector<Entry *> *ArbitrationRound::getParts() {
36 void ArbitrationRound::removeParts(Vector<Entry *> * removeParts) {
37 parts->removeAll(removeParts);
42 bool ArbitrationRound::isDoneSending() {
43 if ((commit == NULL) && abortsBefore->isEmpty()) {
47 return parts->isEmpty();
50 Commit *ArbitrationRound::getCommit() {
54 void ArbitrationRound::setCommit(Commit *_commit) {
56 currentSize -= commit->getNumberOfParts();
61 currentSize += commit->getNumberOfParts();
65 void ArbitrationRound::addAbort(Abort *abort) {
66 abortsBefore->add(abort);
70 void ArbitrationRound::addAborts(Hashset<Abort *> *aborts) {
71 abortsBefore->addAll(aborts);
72 currentSize += aborts->size();
75 Hashset<Abort *> *ArbitrationRound::getAborts() {
79 int ArbitrationRound::getAbortsCount() {
80 return abortsBefore->size();
83 int ArbitrationRound::getCurrentSize() {
87 bool ArbitrationRound::isFull() {
88 return currentSize >= MAX_PARTS;
91 bool ArbitrationRound::getDidSendPart() {