| | |
| | | typedef std::function<Data(const Data)> Handler; |
| | | bool ClientRequest(const Data request, Data &reply); |
| | | bool ServerProcess(Handler onReq); |
| | | AtomicReqRep() : |
| | | data_(0), timestamp_(now()) {} |
| | | |
| | | private: |
| | | enum State { |
| | |
| | | static Data Decode(Data d) { return d >> 3; } |
| | | typedef std::chrono::steady_clock steady_clock; |
| | | typedef steady_clock::duration Duration; |
| | | Duration now() { return steady_clock::now().time_since_epoch(); } |
| | | static Duration now() { return steady_clock::now().time_since_epoch(); } |
| | | |
| | | bool DataCas(Data expected, Data val) { return data_.compare_exchange_strong(expected, val); } |
| | | std::atomic<Data> data_; |