16 #ifndef HAZELCAST_CLIENT_PIPELINING_H_ 17 #define HAZELCAST_CLIENT_PIPELINING_H_ 21 #include "hazelcast/client/ICompletableFuture.h" 22 #include "hazelcast/util/Preconditions.h" 23 #include "hazelcast/util/ConditionVariable.h" 24 #include "hazelcast/util/concurrent/ConcurrencyUtil.h" 76 class Pipelining :
public boost::enable_shared_from_this<Pipelining<E> > {
89 static boost::shared_ptr<Pipelining>
create(
int depth) {
90 util::Preconditions::checkPositive(depth,
"depth must be positive");
92 return boost::shared_ptr<Pipelining>(
new Pipelining(depth));
105 std::vector<boost::shared_ptr<E> >
results() {
106 std::vector<boost::shared_ptr<E> > result(futures.size());
108 for (
typename FuturesVector::const_iterator it = futures.begin(); it != futures.end(); ++it, ++index) {
109 result[index] = (*it)->get();
124 const boost::shared_ptr<ICompletableFuture<E> > &
126 util::Preconditions::checkNotNull<ICompletableFuture<E> >(future,
"future can't be null");
129 futures.push_back(future);
131 new PipeliningExecutionCallback(this->shared_from_this())),
132 util::concurrent::ConcurrencyUtil::CALLER_RUNS());
139 PipeliningExecutionCallback(
const boost::shared_ptr<Pipelining> &pipelining) : pipelining(pipelining) {}
141 virtual void onResponse(
const boost::shared_ptr<E> &response) {
145 virtual void onFailure(
const boost::shared_ptr<exception::IException> &e) {
150 const boost::shared_ptr<Pipelining> pipelining;
153 Pipelining(
int depth) : permits(util::Preconditions::checkPositive(depth,
"depth must be positive")) {
158 util::LockGuard lockGuard(mutex);
159 while (permits == 0) {
160 conditionVariable.wait(mutex);
166 util::LockGuard lockGuard(mutex);
168 conditionVariable.notify_all();
173 typedef std::vector<boost::shared_ptr<ICompletableFuture<E> > > FuturesVector;
175 std::vector<boost::shared_ptr<ICompletableFuture<E> > > futures;
176 util::ConditionVariable conditionVariable;
182 #endif //HAZELCAST_CLIENT_PIPELINING_H_ std::vector< boost::shared_ptr< E > > results()
Returns the results.
Definition: Pipelining.h:105
const boost::shared_ptr< ICompletableFuture< E > > & add(const boost::shared_ptr< ICompletableFuture< E > > &future)
Adds a future to this Pipelining or blocks until there is capacity to add the future to the Pipelinin...
Definition: Pipelining.h:125
static boost::shared_ptr< Pipelining > create(int depth)
Creates a Pipelining with the given depth.
Definition: Pipelining.h:89
A Future where one can asynchronously listen on completion.
Definition: ICompletableFuture.h:38
Definition: Pipelining.h:76
PN (Positive-Negative) CRDT counter.
Definition: MapEntryView.h:32