diff options
| author | Michael Bebenita <[email protected]> | 2010-07-19 14:05:18 -0700 |
|---|---|---|
| committer | Michael Bebenita <[email protected]> | 2010-07-19 14:05:18 -0700 |
| commit | 00d1465d13980fc3acf650f182ee0723fbda0e06 (patch) | |
| tree | a73cf5f0f20c0bee6722b33d975eb930919fefdf /src/rt/circular_buffer.h | |
| parent | Add a test for an obvious-seeming (but not actually legal) kind of cast attem... (diff) | |
| download | rust-00d1465d13980fc3acf650f182ee0723fbda0e06.tar.xz rust-00d1465d13980fc3acf650f182ee0723fbda0e06.zip | |
Added a message passing system based on lock free queues for inter-thread communication. Channels now buffer on the sending side, and no longer require blocking when sending. Lots of other refactoring and bug fixes.
Diffstat (limited to 'src/rt/circular_buffer.h')
| -rw-r--r-- | src/rt/circular_buffer.h | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/src/rt/circular_buffer.h b/src/rt/circular_buffer.h new file mode 100644 index 00000000..c0c0da5e --- /dev/null +++ b/src/rt/circular_buffer.h @@ -0,0 +1,30 @@ +/* + * + */ + +#ifndef CIRCULAR_BUFFER_H +#define CIRCULAR_BUFFER_H + +class +circular_buffer : public dom_owned<circular_buffer> { + static const size_t INITIAL_CIRCULAR_BUFFFER_SIZE_IN_UNITS = 8; + static const size_t MAX_CIRCULAR_BUFFFER_SIZE = 1 << 24; + +public: + rust_dom *dom; + circular_buffer(rust_dom *dom, size_t unit_sz); + ~circular_buffer(); + void transfer(void *dst); + void enqueue(void *src); + void dequeue(void *dst); + bool is_empty(); + +private: + size_t _buffer_sz; + size_t unit_sz; + size_t _next; + size_t _unread; + uint8_t *_buffer; +}; + +#endif /* CIRCULAR_BUFFER_H */ |