Слияние кода завершено, страница обновится автоматически
#ifndef MY_FIFO_H
#define MY_FIFO_H
#include "ace/Condition_T.h"
#include "ace/OS.h"
template<typename T>
class my_fifo
{
public:
my_fifo(unsigned long size=10);
public:
virtual ~my_fifo(void);
virtual int init()=0;
virtual int push_back(T content)=0;
virtual int pop_front(T& content)=0;
unsigned int get_element_size();
virtual int destroy();
virtual int disabled();
virtual int enabled();
virtual int clear()=0;
protected:
int is_empty();
int is_full();
unsigned int head;
unsigned int tail;
int full;
unsigned long maxSize;
//ACE_Thread_Mutex mutex;
//ACE_Condition<ACE_Thread_Mutex> condNotfull;
//ACE_Condition<ACE_Thread_Mutex> condNotempty;
ACE_Recursive_Thread_Mutex mutex;
ACE_Condition<ACE_Recursive_Thread_Mutex> condNotfull;
ACE_Condition<ACE_Recursive_Thread_Mutex> condNotempty;
int quit_flag;
};
template<typename T>
my_fifo<T>::my_fifo(unsigned long size):maxSize(size),full(0),head(0),tail(0),condNotfull(mutex),condNotempty(mutex),quit_flag(0)
{
}
template<typename T>
my_fifo<T>::~my_fifo(void)
{
}
template<typename T>
unsigned int my_fifo<T>::get_element_size()
{
ACE_Guard<ACE_Recursive_Thread_Mutex> guard(mutex);
if (is_full()==0)
{
return maxSize;
}
return (tail-head+1+maxSize)%maxSize;
}
template<typename T>
int my_fifo<T>::is_empty()
{
if (full==0&&head==tail)
{
return 0;
}
return -1;
}
template<typename T>
int my_fifo<T>::is_full()
{
if (full==1&&head==tail)
{
return 0;
}
return -1;
}
template<typename T>
int my_fifo<T>::destroy()
{
return -1;
}
template<typename T>
int my_fifo<T>::disabled()
{
return -1;
}
template<typename T>
int my_fifo<T>::enabled()
{
return -1;
}
#endif
Вы можете оставить комментарий после Вход в систему
Неприемлемый контент может быть отображен здесь и не будет показан на странице. Вы можете проверить и изменить его с помощью соответствующей функции редактирования.
Если вы подтверждаете, что содержание не содержит непристойной лексики/перенаправления на рекламу/насилия/вульгарной порнографии/нарушений/пиратства/ложного/незначительного или незаконного контента, связанного с национальными законами и предписаниями, вы можете нажать «Отправить» для подачи апелляции, и мы обработаем ее как можно скорее.
Опубликовать ( 0 )