lichao
2021-06-01 43d4e95770b0519341153202c9a535aaa8e164c5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/*
 * =====================================================================================
 *
 *       Filename:  shm_queue.h
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  2021年03月25日 10时35分09秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Li Chao (), 
 *   Organization:  
 *
 * =====================================================================================
 */
 
#ifndef SHM_QUEUE_JE0OEUP3
#define SHM_QUEUE_JE0OEUP3
 
#include "robust.h"
#include "shm.h"
#include <atomic>
#include <boost/circular_buffer.hpp>
#include <chrono>
 
namespace bhome_shm
{
 
// just wrap robust::AtomicQ63
class SharedQ63
{
public:
    template <class... T>
    explicit SharedQ63(T &&...t) {} // easy testing
 
    typedef robust::AtomicQ63 AQ63;
    typedef AQ63::Data Data;
    bool TryRead(Data &d, const bool try_more = true) { return queue_.pop(d, try_more); }
    bool TryWrite(const Data d, const bool try_more = true) { return queue_.push(d, try_more); }
 
private:
    AQ63 queue_;
};
 
} // namespace bhome_shm
 
#endif // end of include guard: SHM_QUEUE_JE0OEUP3