scheduler.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* * Copyright (c) 2013-2016, The Tor Project, Inc. */
  2. /* See LICENSE for licensing information */
  3. /**
  4. * \file scheduler.h
  5. * \brief Header file for scheduler.c
  6. **/
  7. #ifndef TOR_SCHEDULER_H
  8. #define TOR_SCHEDULER_H
  9. #include "or.h"
  10. #include "channel.h"
  11. #include "testsupport.h"
  12. /* Global-visibility scheduler functions */
  13. /* Set up and shut down the scheduler from main.c */
  14. void scheduler_free_all(void);
  15. void scheduler_init(void);
  16. MOCK_DECL(void, scheduler_run, (void));
  17. /* Mark channels as having cells or wanting/not wanting writes */
  18. MOCK_DECL(void,scheduler_channel_doesnt_want_writes,(channel_t *chan));
  19. MOCK_DECL(void,scheduler_channel_has_waiting_cells,(channel_t *chan));
  20. void scheduler_channel_wants_writes(channel_t *chan);
  21. /* Notify the scheduler of a channel being closed */
  22. MOCK_DECL(void,scheduler_release_channel,(channel_t *chan));
  23. /* Notify scheduler of queue size adjustments */
  24. void scheduler_adjust_queue_size(channel_t *chan, int dir, uint64_t adj);
  25. /* Notify scheduler that a channel's queue position may have changed */
  26. void scheduler_touch_channel(channel_t *chan);
  27. /* Adjust the watermarks from config file*/
  28. void scheduler_set_watermarks(uint32_t lo, uint32_t hi, uint32_t max_flush);
  29. /* Things only scheduler.c and its test suite should see */
  30. #ifdef SCHEDULER_PRIVATE_
  31. MOCK_DECL(STATIC int, scheduler_compare_channels,
  32. (const void *c1_v, const void *c2_v));
  33. STATIC uint64_t scheduler_get_queue_heuristic(void);
  34. STATIC void scheduler_update_queue_heuristic(time_t now);
  35. #ifdef TOR_UNIT_TESTS
  36. extern smartlist_t *channels_pending;
  37. extern struct event *run_sched_ev;
  38. extern uint64_t queue_heuristic;
  39. extern time_t queue_heuristic_timestamp;
  40. #endif
  41. #endif
  42. #endif /* !defined(TOR_SCHEDULER_H) */