no message

master
caiyuzheng 2021-05-03 02:11:53 +08:00
parent b08b85026e
commit 662860689d
3 changed files with 12 additions and 2 deletions

View File

@ -27,6 +27,7 @@ public:
private: private:
}; };
template<typename T> template<typename T>
int Observed<T>::AddObserver(Observer<T> *p) { int Observed<T>::AddObserver(Observer<T> *p) {
if(nullptr == p){ if(nullptr == p){
@ -42,6 +43,7 @@ int Observed<T>::AddObserver(Observer<T> *p) {
this->m_vObservers.push_back(p); this->m_vObservers.push_back(p);
return 0; return 0;
} }
template<typename T> template<typename T>
int Observed<T>::DeleteObserver(Observer<T> *p) { int Observed<T>::DeleteObserver(Observer<T> *p) {
for(typename std::vector<Observer<T>*>::iterator itr = m_vObservers.begin(); for(typename std::vector<Observer<T>*>::iterator itr = m_vObservers.begin();
@ -63,4 +65,5 @@ int Observed<T>::NoticeObserver(T *p) {
} }
return 0; return 0;
} }
#endif //GENERAL_OBSERVER_H #endif //GENERAL_OBSERVER_H

View File

@ -11,7 +11,7 @@ public:
T At(uint64_t pos); T At(uint64_t pos);
RingBuffer(uint64_t size); RingBuffer(uint64_t size);
int Add(T *data,uint64_t len); int Add(T *data,uint64_t len);
int Take(T *data,uint64_t data); int Take(T *data,uint64_t len);
uint32_t CanReadCount(); uint32_t CanReadCount();
uint32_t CanWriteCount(); uint32_t CanWriteCount();
~RingBuffer(); ~RingBuffer();
@ -48,6 +48,9 @@ T RingBuffer<T>::At(uint64_t pos){
template<typename T> template<typename T>
int RingBuffer<T>::Add(T *data,uint64_t len){ int RingBuffer<T>::Add(T *data,uint64_t len){
if(data == nullptr){
return -1;
}
/// 0->n |start|head|.....|tail| /// 0->n |start|head|.....|tail|
if(mCurrentTail > mCurrentHead){ if(mCurrentTail > mCurrentHead){
if(mCurrentTail + len > mSize - 1){ if(mCurrentTail + len > mSize - 1){
@ -60,6 +63,10 @@ int RingBuffer<T>::Add(T *data,uint64_t len){
} }
} }
} }
template<typename T>
int RingBuffer<T>::Take(T *data,uint64_t len){
}
template<typename T> template<typename T>
uint32_t RingBuffer<T>::CanReadCount(){ uint32_t RingBuffer<T>::CanReadCount(){

View File

@ -1,4 +1,4 @@
[requires] [requires]
jsoncpp/1.1.1 lua/1.1.1
[imports] [imports]
.,* -> ./third @ folder=True, ignore_case=True, excludes=*.html *.jpeg .,* -> ./third @ folder=True, ignore_case=True, excludes=*.html *.jpeg