libfoedus-core
FOEDUS Core Library
shared_rendezvous.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2015, Hewlett-Packard Development Company, LP.
3  * This program is free software; you can redistribute it and/or modify it
4  * under the terms of the GNU General Public License as published by the Free
5  * Software Foundation; either version 2 of the License, or (at your option)
6  * any later version.
7  *
8  * This program is distributed in the hope that it will be useful, but WITHOUT
9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
11  * more details. You should have received a copy of the GNU General Public
12  * License along with this program; if not, write to the Free Software
13  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
14  *
15  * HP designates this particular file as subject to the "Classpath" exception
16  * as provided by HP in the LICENSE.txt file that accompanied this code.
17  */
18 #ifndef FOEDUS_SOC_SHARED_RENDEZVOUS_HPP_
19 #define FOEDUS_SOC_SHARED_RENDEZVOUS_HPP_
20 
21 #include "foedus/cxx11.hpp"
24 
25 namespace foedus {
26 namespace soc {
35  public:
36  SharedRendezvous() : signaled_(false), initialized_(false), cond_() { initialize(); }
38 
39  // Disable copy constructors
41  SharedRendezvous& operator=(const SharedRendezvous&) CXX11_FUNC_DELETE;
42 
43  void initialize();
44  void uninitialize();
45  bool is_initialized() const { return initialized_; }
46 
48  bool is_signaled() const {
50  return signaled_;
51  }
53  bool is_signaled_weak() const { return signaled_; }
54 
55 
59  void wait();
60 
65  bool wait_for(uint64_t timeout_nanosec);
66 
73  void signal();
74 
75  private:
77  volatile bool signaled_;
78  bool initialized_;
80  SharedPolling cond_;
81 };
82 
83 } // namespace soc
84 } // namespace foedus
85 #endif // FOEDUS_SOC_SHARED_RENDEZVOUS_HPP_
A one-time single-producer multiple-consumer event synchronization in shared memory for multiple proc...
bool is_signaled() const
returns whether the even has signaled.
Root package of FOEDUS (Fast Optimistic Engine for Data Unification Services).
Definition: assert_nd.hpp:44
bool wait_for(uint64_t timeout_nanosec)
Block until the event happens or the given period elapses.
A polling-wait mechanism that can be placed in shared memory and used from multiple processes...
void signal()
Notify all waiters that the event has happened.
#define CXX11_FINAL
Used in public headers in place of "final" of C++11.
Definition: cxx11.hpp:131
bool is_signaled_weak() const
weak version without fence.
#define CXX11_FUNC_DELETE
Used in public headers in place of " = delete" of C++11.
Definition: cxx11.hpp:128
Atomic fence methods and load/store with fences that work for both C++11/non-C++11 code...
void wait()
Block until the event happens.
void memory_fence_acquire()
Equivalent to std::atomic_thread_fence(std::memory_order_acquire).