/src/rt/rust_port.h

http://github.com/jruderman/rust · C Header · 54 lines · 31 code · 12 blank · 11 comment · 0 complexity · 19b4d075e312d7e15b8cd58ad677f55e MD5 · raw file

  1. #ifndef RUST_PORT_H
  2. #define RUST_PORT_H
  3. #include "rust_globals.h"
  4. #include "circular_buffer.h"
  5. class port_detach_cond : public rust_cond { };
  6. class rust_port : public kernel_owned<rust_port>, public rust_cond {
  7. private:
  8. // Protects ref_count and detach_cond
  9. lock_and_signal ref_lock;
  10. intptr_t ref_count;
  11. port_detach_cond detach_cond;
  12. public:
  13. void ref();
  14. void deref();
  15. public:
  16. rust_port_id id;
  17. rust_kernel *kernel;
  18. rust_task *task;
  19. size_t unit_sz;
  20. circular_buffer buffer;
  21. lock_and_signal lock;
  22. public:
  23. rust_port(rust_task *task, size_t unit_sz);
  24. ~rust_port();
  25. void log_state();
  26. void send(void *sptr);
  27. void receive(void *dptr, uintptr_t *yield);
  28. size_t size();
  29. void begin_detach(uintptr_t *yield);
  30. void end_detach();
  31. };
  32. //
  33. // Local Variables:
  34. // mode: C++
  35. // fill-column: 78;
  36. // indent-tabs-mode: nil
  37. // c-basic-offset: 4
  38. // buffer-file-coding-system: utf-8-unix
  39. // compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
  40. // End:
  41. //
  42. #endif /* RUST_PORT_H */