acquire-worker.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // -*- mode: cpp; mode: fold -*-
  2. // Description /*{{{*/
  3. // $Id: acquire-worker.h,v 1.9 1999/01/20 05:11:25 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 pkgAcquire;
  19. protected:
  20. friend 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. // Load the method and do the startup
  60. bool QueueItem(pkgAcquire::Queue::QItem *Item);
  61. bool Start();
  62. void Pulse();
  63. Worker(Queue *OwnerQ,MethodConfig *Config,pkgAcquireStatus *Log);
  64. Worker(MethodConfig *Config);
  65. ~Worker();
  66. };
  67. #endif