MOTION
0.01
Framework for mixed-protocol multi-party computation
|
Go to the documentation of this file.
27 #include <boost/fiber/condition_variable.hpp>
28 #include <boost/fiber/mutex.hpp>
44 : condition_function_(condition_function) {}
54 std::unique_lock<decltype(mutex_)> lock(mutex_);
55 condition_variable_.wait(lock, condition_function_);
60 template <
typename Tick,
typename Period>
61 bool WaitFor(std::chrono::duration<Tick, Period> duration)
const {
62 std::unique_lock<decltype(mutex_)> lock(mutex_);
63 condition_variable_.wait_for(lock, duration, condition_function_);
64 return condition_function_();
68 void NotifyOne() const noexcept { condition_variable_.notify_one(); }
71 void NotifyAll() const noexcept { condition_variable_.notify_all(); }
76 boost::fibers::mutex&
GetMutex() noexcept {
return mutex_; }
79 mutable boost::fibers::condition_variable condition_variable_;
80 mutable boost::fibers::mutex mutex_;
81 const std::function<bool()> condition_function_;
int main(int ac, char *av[])
Definition: example_template_main.cpp:48
boost::fibers::mutex & GetMutex() noexcept
Get the mutex.
Definition: fiber_condition.h:76
std::unique_ptr< Party > PartyPointer
Definition: party.h:387
Wraps a boost::fibers::condition_variable with a boost::fibers::mutex and a condition checking functi...
Definition: fiber_condition.h:35
std::pair< program_options::variables_map, bool > ParseProgramOptions(int ac, char *av[])
Definition: example_template_main.cpp:78
const std::regex kPartyArgumentRegex("(\\d+),(\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}),(\\d{1,5})")
void NotifyAll() const noexcept
Unblocks all threads waiting for condition_variable_.
Definition: fiber_condition.h:71
Definition: tcp_transport.h:69
bool WaitFor(std::chrono::duration< Tick, Period > duration) const
Blocks until fiber is notified and condition_function_ returns true or duration time has passed.
Definition: fiber_condition.h:61
void NotifyOne() const noexcept
Unblocks one thread waiting for condition_variable_.
Definition: fiber_condition.h:68
std::tuple< std::size_t, std::string, std::uint16_t > ParsePartyArgument(const std::string &party_argument)
Definition: example_template_main.cpp:67
std::vector< TcpConnectionConfiguration > TcpPartiesConfiguration
Definition: tcp_transport.h:62
FiberCondition(const std::function< bool()> condition_function)
Registers the condition function that encapsulates the condition checking.
Definition: fiber_condition.h:43
bool CheckPartyArgumentSyntax(const std::string &party_argument)
Definition: example_template_main.cpp:62
Definition: algorithm_description.cpp:35
help
Definition: geninput.py:150
~FiberCondition()=default
encrypto::motion::RunTimeStatistics EvaluateProtocol(encrypto::motion::PartyPointer &party, std::size_t number_of_simd, encrypto::motion::MpcProtocol protocol, bool check)
Definition: aes128.cpp:56
void Wait() const
Blocks until fiber is notified and condition_function_ returns true.
Definition: fiber_condition.h:53
encrypto::motion::PartyPointer CreateParty(const program_options::variables_map &user_options)
Definition: example_template_main.cpp:137
std::vector< std::unique_ptr< Transport > > SetupConnections()
Definition: tcp_transport.cpp:203