perform.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #if 0
  2. // SPDX-License-Identifier: GPL-3.0-or-later
  3. // Copyright © 2018-2019 Ariadne Devos
  4. // XXX delete? -- react to readyness and completeness
  5. #include <sHT/intrisics.h>
  6. #include "worker.h"
  7. #include <errno.h>
  8. #include <stddef.h>
  9. #include <sys/epoll.h>
  10. #include <sys/socket.h>
  11. __attribute__((nonnull (1, 2)))
  12. static void
  13. sHT_other_task(struct sHT_worker *worker, struct sHT_task *task)
  14. {
  15. sHT_assert(0);
  16. }
  17. __attribute__((nonnull (1, 2)))
  18. static void
  19. sHT_aio_task(struct sHT_worker *worker, struct sHT_task *task)
  20. {
  21. sHT_assert(0);
  22. }
  23. void
  24. sHT_sendstatus_task(struct sHT_worker *worker, struct sHT_task *task)
  25. {
  26. sHT_assert(0);
  27. }
  28. /* The idea of calling read, write, recv, send, accept ... ourselves is that
  29. the worker's variable code (i.e. specialised code for TLS, HTTP, a prime
  30. sieve ...) is somewhat independent of the socket interfaces of the kernel.
  31. The worker can, however, still do this by itself using sHT_TASK_NOTHING.
  32. TODO: This allows us to treat intra-machine communication specially, e.g.
  33. with shared memory. (Note: this would require memory_order_relaxed or
  34. volatile.)
  35. */
  36. void
  37. sHT_perform_task(struct sHT_worker *worker, struct sHT_task *task)
  38. {
  39. /* The C compiler probably knows better than me how this should be
  40. compiled (e.g. with a jump table). */
  41. switch((enum sHT_task_type) (task->flags & sHT_TASK_TYPE_MASK)) {
  42. case sHT_TASK_T_DIY:
  43. sHT_other_task(worker, task);
  44. break;
  45. case sHT_TASK_T_SOCKET_STREAM:
  46. sHT_socket_task(worker, task);
  47. break;
  48. case sHT_TASK_T_ASYNC_IO:
  49. sHT_aio_task(worker, task);
  50. break;
  51. case sHT_TASK_T_ACCEPT:
  52. sHT_accept_task(worker, task);
  53. break;
  54. case sHT_TASK_T_SENDSTATUS:
  55. sHT_sendstatus_task(worker, task);
  56. break;
  57. default:
  58. sHT_assert(0 && task->flags);
  59. }
  60. }
  61. #endif