forked from ravinet/mahimahi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbytestream_queue.hh
More file actions
36 lines (24 loc) · 782 Bytes
/
Copy pathbytestream_queue.hh
File metadata and controls
36 lines (24 loc) · 782 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/* -*-mode:c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
#ifndef BYTESTREAM_QUEUE_HH
#define BYTESTREAM_QUEUE_HH
#include <queue>
#include <string>
#include <functional>
#include "file_descriptor.hh"
class ByteStreamQueue
{
private:
std::string buffer_;
size_t next_byte_to_push, next_byte_to_pop;
size_t available_to_push( void ) const;
size_t available_to_pop( void ) const;
public:
ByteStreamQueue( const size_t size );
enum class Result { Success, EndOfFile };
Result push( FileDescriptor & fd );
void pop( FileDescriptor & fd );
const std::function<bool(void)> space_available;
const std::function<bool(void)> non_empty;
};
bool eof( const ByteStreamQueue::Result & r );
#endif /* BYTESTREAM_QUEUE_HH */