acquire-worker.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: acquire-worker.h,v 1.12 2001/02/20 07:03:17 jgg Exp $
  4. /* ######################################################################
  5. Acquire Worker - Worker process manager
  6. Each worker class is associated with exaclty one subprocess.
  7. ##################################################################### */
  8. /*}}}*/
  9. #ifndef PKGLIB_ACQUIRE_WORKER_H
  10. #define PKGLIB_ACQUIRE_WORKER_H
  11. #include <apt-pkg/acquire.h>
  12. #ifdef __GNUG__
  13. #pragma interface "apt-pkg/acquire-worker.h"
  14. #endif
  15. // Interfacing to the method process
  16. class pkgAcquire::Worker
  17. {
  18. friend class pkgAcquire;
  19. protected:
  20. friend class Queue;
  21. /* Linked list starting at a Queue and a linked list starting
  22. at Acquire */
  23. Worker *NextQueue;
  24. Worker *NextAcquire;
  25. // The access association
  26. Queue *OwnerQ;
  27. pkgAcquireStatus *Log;
  28. MethodConfig *Config;
  29. string Access;
  30. // This is the subprocess IPC setup
  31. pid_t Process;
  32. int InFd;
  33. int OutFd;
  34. bool InReady;
  35. bool OutReady;
  36. // Various internal things
  37. bool Debug;
  38. vector<string> MessageQueue;
  39. string OutQueue;
  40. // Private constructor helper
  41. void Construct();
  42. // Message handling things
  43. bool ReadMessages();
  44. bool RunMessages();
  45. bool InFdReady();
  46. bool OutFdReady();
  47. // The message handlers
  48. bool Capabilities(string Message);
  49. bool SendConfiguration();
  50. bool MediaChange(string Message);
  51. bool MethodFailure();
  52. void ItemDone();
  53. public:
  54. // The curent method state
  55. pkgAcquire::Queue::QItem *CurrentItem;
  56. string Status;
  57. unsigned long CurrentSize;
  58. unsigned long TotalSize;
  59. unsigned long ResumePoint;
  60. // Load the method and do the startup
  61. bool QueueItem(pkgAcquire::Queue::QItem *Item);
  62. bool Start();
  63. void Pulse();
  64. inline const MethodConfig *GetConf() const {return Config;};
  65. Worker(Queue *OwnerQ,MethodConfig *Config,pkgAcquireStatus *Log);
  66. Worker(MethodConfig *Config);
  67. ~Worker();
  68. };
  69. #endif