Hazelcast C++ Client
Hazelcast C++ Client Library
transactional_queue.h
1 /*
2  * Copyright (c) 2008-2022, 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 #pragma once
17 
18 #include "hazelcast/client/proxy/TransactionalQueueImpl.h"
19 
20 namespace hazelcast {
21 namespace client {
27 class HAZELCAST_API transactional_queue : public proxy::TransactionalQueueImpl
28 {
29  friend class transaction_context;
30 
31 public:
37  template<typename E>
38  boost::future<bool> offer(const E& e)
39  {
40  return offer(e, std::chrono::milliseconds::zero());
41  }
42 
49  template<typename E>
50  boost::future<bool> offer(const E& e, std::chrono::milliseconds timeout)
51  {
52  return proxy::TransactionalQueueImpl::offer(to_data(e), timeout);
53  }
54 
60  template<typename E>
61  boost::future<boost::optional<E>> poll()
62  {
63  return poll<E>(std::chrono::milliseconds::zero());
64  }
65 
72  template<typename E>
73  boost::future<boost::optional<E>> poll(std::chrono::milliseconds timeout)
74  {
75  return to_object<E>(proxy::TransactionalQueueImpl::poll_data(timeout));
76  }
77 
78 private:
79  transactional_queue(const std::string& name,
80  txn::TransactionProxy& transaction_proxy)
81  : proxy::TransactionalQueueImpl(name, transaction_proxy)
82  {}
83 };
84 } // namespace client
85 } // namespace hazelcast
Provides a context to do transactional operations; so beginning/committing transactions,...
Transactional implementation of iqueue.
boost::future< bool > offer(const E &e)
Transactional implementation of iqueue::offer(const E &e)
boost::future< bool > offer(const E &e, std::chrono::milliseconds timeout)
Transactional implementation of iqueue::offer(const E &e, std::chrono::milliseconds timeout)
boost::future< boost::optional< E > > poll()
Transactional implementation of iqueue::poll()
boost::future< boost::optional< E > > poll(std::chrono::milliseconds timeout)
Transactional implementation of iqueue::poll(std::chrono::milliseconds timeout)