chiark / gitweb /
admin: Implement job table infrastructure.
[tripe] / server / tripe.h
index 1cb2d4078687b59ecd2c746a32b0740837139f5b..1d13f32d99180a444c004c1c7362baf371167497 100644 (file)
@@ -400,6 +400,28 @@ typedef struct admin_service {
   struct admin_service *next, *prev;   /* Client's list of services */
 } admin_service;
 
+typedef struct admin_svcop {
+  admin_bgop bg;                       /* Background operation header */
+  struct admin *prov;                  /* Client servicing this job */
+  unsigned short index;                        /* This job's index */
+  struct admin_svcop *next, *prev;     /* Links for provider's jobs */
+} admin_svcop;
+
+typedef struct admin_jobentry {
+  unsigned short seq;                  /* Zero if unused */
+  union {
+    admin_svcop *op;                   /* Operation, if slot in use, ... */
+    uint32 next;                       /* ... or index of next free slot */
+  } u;
+} admin_jobentry;
+
+typedef struct admin_jobtable {
+  uint32 n, sz;                                /* Used slots and table size */
+  admin_svcop *active;                 /* List of active jobs */
+  uint32 free;                         /* Index of first free slot */
+  admin_jobentry *v;                   /* And the big array of entries */
+} admin_jobtable;
+
 typedef struct admin {
   struct admin *next, *prev;           /* Links to next and previous */
   unsigned f;                          /* Various useful flags */
@@ -411,6 +433,7 @@ typedef struct admin {
   oqueue delay;                                /* Delayed output buffer list */
   admin_bgop *bg;                      /* Backgrounded operations */
   admin_service *svcs;                 /* Which services I provide */
+  admin_jobtable j;                    /* Table of outstanding jobs */
   selbuf b;                            /* Line buffer for commands */
   sel_file w;                          /* Selector for write buffering */
 } admin;