A platform for high-performance distributed tool and library development written in C++. It can be deployed in two different cluster modes: standalone or distributed. API for v0.5.0, released on June 13, 2018.
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
PageCircularBufferIterator.cc
Go to the documentation of this file.
1
/*****************************************************************************
2
* *
3
* Copyright 2018 Rice University *
4
* *
5
* Licensed under the Apache License, Version 2.0 (the "License"); *
6
* you may not use this file except in compliance with the License. *
7
* You may obtain a copy of the License at *
8
* *
9
* http://www.apache.org/licenses/LICENSE-2.0 *
10
* *
11
* Unless required by applicable law or agreed to in writing, software *
12
* distributed under the License is distributed on an "AS IS" BASIS, *
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
14
* See the License for the specific language governing permissions and *
15
* limitations under the License. *
16
* *
17
*****************************************************************************/
18
19
#ifndef PAGECIRCULARBUFFERITERATOR_CC
20
#define PAGECIRCULARBUFFERITERATOR_CC
21
22
#include "
PDBDebug.h
"
23
#include "
PageCircularBufferIterator.h
"
24
#include "
PageCircularBuffer.h
"
25
#include <iostream>
26
using namespace
std;
27
PageCircularBufferIterator::PageCircularBufferIterator
(
unsigned
int
id
,
28
PageCircularBufferPtr
buffer,
29
pdb::PDBLoggerPtr
logger) {
30
this->
id
= id;
31
this->buffer = buffer;
32
this->logger = logger;
33
}
34
35
PageCircularBufferIterator::~PageCircularBufferIterator
() {}
36
37
// will block when queue is empty and will remove the page from queue before return;
38
PDBPagePtr
PageCircularBufferIterator::next
() {
39
return
this->buffer->popPageFromHead();
40
}
41
42
/* Potential Bug: in certain cases, two iterators may simultaneously find that the buffer is closed,
43
* but there are still data in the buffer. In this case, one iterator will not be able
44
* to get a page, although it says hasNext() == true.
45
*
46
* Solution 1: wait for all elements in the queue to be fetched, then close the queue;
47
* Solution 2: allow that you may get a nullptr by calling next(), and it is your responsibility to
48
* check that!
49
*
50
* Now, we go solution 2, please let me know if this is a problem!
51
*/
52
bool
PageCircularBufferIterator::hasNext
() {
53
bool
ret = ((!this->buffer->isClosed()) || (!this->buffer->isEmpty()));
54
PDB_COUT
<<
"iter Id="
<< this->
id
<<
",ret="
<< ret <<
"\n"
;
55
return
ret;
56
}
57
58
unsigned
int
PageCircularBufferIterator::getId
() {
59
return
this->id;
60
}
61
62
63
#endif
PDBPagePtr
shared_ptr< PDBPage > PDBPagePtr
Definition:
PDBPage.h:32
PDBDebug.h
PageCircularBufferIterator.h
PageCircularBufferIterator::hasNext
bool hasNext() override
Definition:
PageCircularBufferIterator.cc:52
PageCircularBufferIterator::PageCircularBufferIterator
PageCircularBufferIterator(unsigned int id, PageCircularBufferPtr buffer, pdb::PDBLoggerPtr logger)
Definition:
PageCircularBufferIterator.cc:27
PageCircularBufferIterator::next
PDBPagePtr next() override
Definition:
PageCircularBufferIterator.cc:38
PageCircularBufferIterator::~PageCircularBufferIterator
~PageCircularBufferIterator()
Definition:
PageCircularBufferIterator.cc:35
PageCircularBuffer.h
PDB_COUT
#define PDB_COUT
Definition:
PDBDebug.h:31
pdb::PDBLoggerPtr
std::shared_ptr< PDBLogger > PDBLoggerPtr
Definition:
PDBLogger.h:40
PageCircularBufferPtr
shared_ptr< PageCircularBuffer > PageCircularBufferPtr
Definition:
PageCircularBuffer.h:27
PageCircularBufferIterator::getId
unsigned int getId()
Definition:
PageCircularBufferIterator.cc:58
plinycompute
pdb
src
storage
source
PageCircularBufferIterator.cc
Generated on Mon Jun 18 2018 18:10:37 by
1.8.6