larbin源碼分析----PersistentFifo

此隊列裏面存入的是url對象 socket

 

class PersistentFifo { ide

 protected: ui

  uint in, out;      //隊列標誌位,入口 出口 this

#ifdef THREAD_OUTPUT url

  pthread_mutex_t lock; spa

#endif orm

  // number of the file used for reading 對象

  int fin, fout; 隊列

  // name of files ci

  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

相關文章
相關標籤/搜索