PageRenderTime 49ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/elements/simple/simplerrsched.cc

https://github.com/bhesmans/click
C++ | 50 lines | 29 code | 5 blank | 16 comment | 3 complexity | 8d94f92d108fe989ee6ea97cb980be63 MD5 | raw file
Possible License(s): GPL-2.0, BSD-3-Clause
  1. /*
  2. * rrsched.{cc,hh} -- round robin scheduler element
  3. * Robert Morris, Eddie Kohler
  4. *
  5. * Copyright (c) 1999-2000 Massachusetts Institute of Technology
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a
  8. * copy of this software and associated documentation files (the "Software"),
  9. * to deal in the Software without restriction, subject to the conditions
  10. * listed in the Click LICENSE file. These conditions include: you must
  11. * preserve this copyright notice, and you cannot mention the copyright
  12. * holders in advertising related to the Software without their permission.
  13. * The Software is provided WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED. This
  14. * notice is a summary of the Click LICENSE file; the license in that file is
  15. * legally binding.
  16. */
  17. #include <click/config.h>
  18. #include "simplerrsched.hh"
  19. CLICK_DECLS
  20. SimpleRRSched::SimpleRRSched()
  21. {
  22. _next = 0;
  23. }
  24. SimpleRRSched::~SimpleRRSched()
  25. {
  26. }
  27. Packet *
  28. SimpleRRSched::pull(int)
  29. {
  30. int n = ninputs();
  31. int i = _next;
  32. for (int j = 0; j < n; j++) {
  33. Packet *p = input(i).pull();
  34. i++;
  35. if (i >= n)
  36. i = 0;
  37. if (p) {
  38. _next = i;
  39. return p;
  40. }
  41. }
  42. return 0;
  43. }
  44. CLICK_ENDDECLS
  45. EXPORT_ELEMENT(SimpleRRSched)