Hazelcast C++ Client
Hazelcast C++ Client Library
transactional_queue.h
1 /*
2  * Copyright (c) 2008-2021, 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  friend class transaction_context;
29  public:
35  template<typename E>
36  boost::future<bool> offer(const E &e) {
37  return offer(e, std::chrono::milliseconds::zero());
38  }
39 
45  template<typename E>
46  boost::future<bool> offer(const E &e, std::chrono::milliseconds timeout) {
47  return proxy::TransactionalQueueImpl::offer(to_data(e), timeout);
48  }
49 
55  template<typename E>
56  boost::future<boost::optional<E>> poll() {
57  return poll<E>(std::chrono::milliseconds::zero());
58  }
59 
65  template<typename E>
66  boost::future<boost::optional<E>> poll(std::chrono::milliseconds timeout) {
67  return to_object<E>(proxy::TransactionalQueueImpl::poll_data(timeout));
68  }
69 
70  private:
71  transactional_queue(const std::string &name, txn::TransactionProxy &transaction_proxy)
72  : proxy::TransactionalQueueImpl(name, transaction_proxy) {
73 
74  }
75  };
76  }
77 }
78 
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)