acquire-worker.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. // Interfacing to the method process
  13. class pkgAcquire::Worker
  14. {
  15. friend class pkgAcquire;
  16. protected:
  17. friend class Queue;
  18. /* Linked list starting at a Queue and a linked list starting
  19. at Acquire */
  20. Worker *NextQueue;
  21. Worker *NextAcquire;
  22. // The access association
  23. Queue *OwnerQ;
  24. pkgAcquireStatus *Log;
  25. MethodConfig *Config;
  26. string Access;
  27. // This is the subprocess IPC setup
  28. pid_t Process;
  29. int InFd;
  30. int OutFd;
  31. bool InReady;
  32. bool OutReady;
  33. // Various internal things
  34. bool Debug;
  35. vector<string> MessageQueue;
  36. string OutQueue;
  37. // Private constructor helper
  38. void Construct();
  39. // Message handling things
  40. bool ReadMessages();
  41. bool RunMessages();
  42. bool InFdReady();
  43. bool OutFdReady();
  44. // The message handlers
  45. bool Capabilities(string Message);
  46. bool SendConfiguration();
  47. bool MediaChange(string Message);
  48. bool MethodFailure();
  49. void ItemDone();
  50. public:
  51. // The curent method state
  52. pkgAcquire::Queue::QItem *CurrentItem;
  53. string Status;
  54. unsigned long CurrentSize;
  55. unsigned long TotalSize;
  56. unsigned long ResumePoint;
  57. // Load the method and do the startup
  58. bool QueueItem(pkgAcquire::Queue::QItem *Item);
  59. bool Start();
  60. void Pulse();
  61. inline const MethodConfig *GetConf() const {return Config;};
  62. Worker(Queue *OwnerQ,MethodConfig *Config,pkgAcquireStatus *Log);
  63. Worker(MethodConfig *Config);
  64. ~Worker();
  65. };
  66. #endif