此队列里面存入的是url对象

 

class PersistentFifo {

 protected:

  uint in, out;      //队列标志位,入口 出口

#ifdef THREAD_OUTPUT

  pthread_mutex_t lock;

#endif

  // number of the file used for reading

  int fin, fout;

  // name of files

  uint fileNameLength;

  char *fileName;

  // Make fileName fit with this number

  void makeName (uint nb);

  // Give a file name for this int

  int getNumber (char *file);

  // Change the file used for reading

  void updateRead ();             //改变“读文件”

  // Change the file used for writing

  void updateWrite ();            //改变“写”文件

  // buffer used for readLine

  char outbuf[BUF_SIZE];          //输出缓冲

  // number of char used in this buffer

  uint outbufPos;

  // buffer used for readLine

  char buf[BUF_SIZE];             //用此buf作写操作

  // number of char used in this buffer

  uint bufPos, bufEnd;             //缓冲标识符  开始 结束

  // sockets for reading and writing

  int rfds, wfds;

  // read a line on rfds

  char *readLine ();

  // write an url in the out file (buffered write)

  void writeUrl (char *s);

  // Flush the out Buffer in the outFile

  void flushOut ();

 

 public:

  /* Specific constructor */

  PersistentFifo (bool reload, char *baseName);

 

  /* Destructor */

  ~PersistentFifo ();

 

  /* get the first object (non totally blocking)

   * return NULL if there is none

   */

  url *tryGet ();

 

  /* get the first object (non totally blocking)

   * probably crash if there is none

   */

  url *get ();

 

  /* add an object in the fifo */

  void put (url *obj);

 

  /* how many items are there inside ? */

  int getLength ();

};

 

#endif // PERSFIFO_H