MOTION  0.01
Framework for mixed-protocol multi-party computation
gate_executor.h
Go to the documentation of this file.
1 // MIT License
2 //
3 // Copyright (c) 2020 Lennart Braun
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in all
13 // copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 // SOFTWARE.
22 
23 #pragma once
24 
25 #include <functional>
26 #include <memory>
27 
28 namespace encrypto::motion {
29 
30 struct RunTimeStatistics;
31 
32 class Logger;
33 class Register;
34 
35 // Evaluates all registered gates.
36 class GateExecutor {
37  public:
38  GateExecutor(Register&, std::function<void()> preprocessing_function, std::shared_ptr<Logger>);
39 
40  // Run the setup phases first for all gates before starting with the online
41  // phases.
42  void EvaluateSetupOnline(RunTimeStatistics& statistics);
43  // Run setup and online phase of each gate as soon as possible.
44  void Evaluate(RunTimeStatistics& statistics);
45 
46  private:
47  Register& register_;
48  std::function<void()> preprocessing_function_;
49  std::shared_ptr<Logger> logger_;
50 };
51 
52 } // namespace encrypto::motion
fiber_thread_pool.hpp
encrypto::motion::RunTimeStatistics::RecordEnd
void RecordEnd()
Definition: run_time_statistics.h:62
encrypto::motion::Register::GetTotalNumberOfGates
std::size_t GetTotalNumberOfGates() const
Definition: register.h:98
encrypto::motion::FiberThreadPool::post
void post(task_t task)
Definition: fiber_thread_pool.cpp:148
encrypto::motion::Register::GetNumberOfEvaluatedGateSetups
std::size_t GetNumberOfEvaluatedGateSetups() const
Definition: register.h:94
encrypto::motion::GateExecutor::Evaluate
void Evaluate(RunTimeStatistics &statistics)
Definition: gate_executor.cpp:89
encrypto::motion::RunTimeStatistics::StatisticsId::kEvaluate
@ kEvaluate
encrypto::motion::Register::GetGates
auto & GetGates() const
Definition: register.h:74
encrypto::motion::RunTimeStatistics::StatisticsId::kGatesOnline
@ kGatesOnline
encrypto::motion::FiberThreadPool
Definition: fiber_thread_pool.hpp:41
register.h
logger.h
encrypto::motion
Definition: algorithm_description.cpp:35
encrypto::motion::Register::GetNumberOfEvaluatedGates
std::size_t GetNumberOfEvaluatedGates() const
Definition: register.h:96
encrypto::motion::Register::ClearActiveQueue
void ClearActiveQueue()
Definition: register.cpp:96
encrypto::motion::RunTimeStatistics
Definition: run_time_statistics.h:32
encrypto::motion::GateExecutor::GateExecutor
GateExecutor(Register &, std::function< void()> preprocessing_function, std::shared_ptr< Logger >)
Definition: gate_executor.cpp:33
encrypto::motion::GateExecutor::EvaluateSetupOnline
void EvaluateSetupOnline(RunTimeStatistics &statistics)
Definition: gate_executor.cpp:39
encrypto::motion::Register::GetGatesSetupDoneCondition
std::shared_ptr< FiberCondition > GetGatesSetupDoneCondition()
Definition: register.h:104
encrypto::motion::Register
Definition: register.h:48
encrypto::motion::RunTimeStatistics::StatisticsId::kGatesSetup
@ kGatesSetup
gate.h
encrypto::motion::FiberThreadPool::join
void join()
Definition: fiber_thread_pool.cpp:140
encrypto::motion::Register::GetGatesOnlineDoneCondition
std::shared_ptr< FiberCondition > GetGatesOnlineDoneCondition()
Definition: register.h:108
gate_executor.h
run_time_statistics.h
encrypto::motion::RunTimeStatistics::RecordStart
void RecordStart()
Definition: run_time_statistics.h:56
encrypto::motion::GateExecutor
Definition: gate_executor.h:36