| Apache Ignite C++

compute.h
Go to the documentation of this file.
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. 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
23 #ifndef _IGNITE_COMPUTE_COMPUTE
24 #define _IGNITE_COMPUTE_COMPUTE
25
26 #include <ignite/common/common.h>
27
28 #include <ignite/ignite_error.h>
29 #include <ignite/future.h>
30 #include <ignite/compute/compute_func.h>
31
32 #include <ignite/impl/compute/compute_impl.h>
33
34 namespace ignite
35 {
36 namespace compute
37 {
74 class IGNITE_IMPORT_EXPORT Compute
75 {
76 public:
84 Compute(common::concurrent::SharedPointer<impl::compute::ComputeImpl> impl) :
85 impl(impl)
86 {
87 // No-op.
88 }
89
103 template<typename R, typename F>
104 R Call(const F& func)
105 {
106 return impl.Get()->CallAsync<R, F>(func).GetValue();
107 }
108
123 template<typename R, typename F>
124 Future<R> CallAsync(const F& func)
125 {
126 return impl.Get()->CallAsync<R, F>(func);
127 }
128
138 template<typename F>
139 void Run(const F& action)
140 {
141 return impl.Get()->RunAsync<F>(action).GetValue();
142 }
143
154 template<typename F>
155 Future<void> RunAsync(const F& action)
156 {
157 return impl.Get()->RunAsync<F>(action);
158 }
159
171 template<typename R, typename F>
172 std::vector<R> Broadcast(const F& func)
173 {
174 return impl.Get()->BroadcastAsync<R, F>(func).GetValue();
175 }
176
185 template<typename F>
186 void Broadcast(const F& func)
187 {
188 impl.Get()->BroadcastAsync<F, false>(func).GetValue();
189 }
190
204 template<typename R, typename F>
205 Future< std::vector<R> > BroadcastAsync(const F& func)
206 {
207 return impl.Get()->BroadcastAsync<R, F>(func);
208 }
209
220 template<typename F>
221 Future<void> BroadcastAsync(const F& func)
222 {
223 return impl.Get()->BroadcastAsync<F, false>(func);
224 }
225
226 private:
228 common::concurrent::SharedPointer<impl::compute::ComputeImpl> impl;
229 };
230 }
231 }
232
233 #endif //_IGNITE_COMPUTE_COMPUTE
ignite::compute::Compute::Call
R Call(const F &func)
Calls provided ComputeFunc on a node within the underlying cluster group.
Definition: compute.h:104
ignite::compute::Compute::CallAsync
Future< R > CallAsync(const F &func)
Asyncronuously calls provided ComputeFunc on a node within the underlying cluster group...
Definition: compute.h:124
ignite::compute::Compute::RunAsync
Future< void > RunAsync(const F &action)
Asyncronuously runs provided ComputeFunc on a node within the underlying cluster group.
Definition: compute.h:155
ignite::Future< void >
Specialization for void type.
Definition: future.h:167
ignite::compute::Compute
Defines compute grid functionality for executing tasks and closures over nodes in the ClusterGroup...
Definition: compute.h:74
ignite::compute::Compute::Broadcast
void Broadcast(const F &func)
Broadcasts provided ComputeFunc to all nodes in the cluster group.
Definition: compute.h:186
ignite::compute::Compute::Compute
Compute(common::concurrent::SharedPointer< impl::compute::ComputeImpl > impl)
Constructor.
Definition: compute.h:84
compute_func.h
Declares ignite::compute::ComputeFunc class template.
ignite::compute::Compute::Run
void Run(const F &action)
Runs provided ComputeFunc on a node within the underlying cluster group.
Definition: compute.h:139
future.h
Declares ignite::Future class template.
ignite::compute::Compute::Broadcast
std::vector< R > Broadcast(const F &func)
Broadcasts provided ComputeFunc to all nodes in the cluster group.
Definition: compute.h:172
ignite
Apache Ignite API.
Definition: cache.h:48
ignite_error.h
Declares ignite::IgniteError class.
ignite::Future
Future class template.
Definition: future.h:46
ignite::compute::Compute::BroadcastAsync
Future< std::vector< R > > BroadcastAsync(const F &func)
Asyncronuously broadcasts provided ComputeFunc to all nodes in the cluster group. ...
Definition: compute.h:205
ignite::compute::Compute::BroadcastAsync
Future< void > BroadcastAsync(const F &func)
Asyncronuously broadcasts provided ComputeFunc to all nodes in the cluster group. ...
Definition: compute.h:221