Hazelcast C++ Client
TransactionalQueue.h
1 /*
2  * Copyright (c) 2008-2018, Hazelcast, Inc. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 //
17 // Created by sancar koyunlu on 8/5/13.
18 
19 #ifndef HAZELCAST_TransactionalQueue
20 #define HAZELCAST_TransactionalQueue
21 
22 #include "hazelcast/client/proxy/TransactionalQueueImpl.h"
23 
24 namespace hazelcast {
25  namespace client {
26  namespace adaptor {
27  template<typename E>
28  class RawPointerTransactionalQueue;
29  }
30 
37  template<typename E>
38  class TransactionalQueue : public proxy::TransactionalQueueImpl {
39  friend class TransactionContext;
41 
42  public:
48  bool offer(const E& e) {
49  return offer(e, 0);
50  }
51 
57  bool offer(const E& e, long timeoutInMillis) {
58  return proxy::TransactionalQueueImpl::offer(toData(&e), timeoutInMillis);
59  }
60 
66  boost::shared_ptr<E> poll() {
67  return poll(0);
68  }
69 
75  boost::shared_ptr<E> poll(long timeoutInMillis) {
76  return boost::shared_ptr<E>(toObject<E>(proxy::TransactionalQueueImpl::pollData(timeoutInMillis)));
77  }
78 
84  int size() {
85  return proxy::TransactionalQueueImpl::size();
86  }
87 
88  private:
89  TransactionalQueue(const std::string& name, txn::TransactionProxy *transactionProxy)
90  : proxy::TransactionalQueueImpl(name, transactionProxy) {
91 
92  }
93  };
94  }
95 }
96 
97 #endif //HAZELCAST_TransactionalQueue
98 
bool offer(const E &e)
Transactional implementation of IQueue::offer(const E &e)
Definition: TransactionalQueue.h:48
boost::shared_ptr< E > poll()
Transactional implementation of IQueue::poll()
Definition: TransactionalQueue.h:66
Transactional implementation of IQueue.
Definition: RawPointerTransactionalQueue.h:34
int size()
Transactional implementation of IQueue::size()
Definition: TransactionalQueue.h:84
boost::shared_ptr< E > poll(long timeoutInMillis)
Transactional implementation of IQueue::poll(long timeoutInMillis)
Definition: TransactionalQueue.h:75
PN (Positive-Negative) CRDT counter.
Definition: MapEntryView.h:32
Transactional implementation of IQueue.
Definition: TransactionalQueue.h:38
bool offer(const E &e, long timeoutInMillis)
Transactional implementation of IQueue::offer(const E &e, long timeoutInMillis)
Definition: TransactionalQueue.h:57
Provides a context to do transactional operations; so beginning/committing transactions, but also retrieving transactional data-structures like the TransactionalMap.
Definition: TransactionContext.h:54