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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
/*
CLASS:flow_controlled:
*/
#ifndef GABA_DEFINE
struct flow_controlled
{
struct lsh_object super;
void (*(report))(struct flow_controlled *self,uint32_t);
};
extern struct lsh_class flow_controlled_class;
#endif /* !GABA_DEFINE */
#ifndef GABA_DECLARE
struct lsh_class flow_controlled_class =
{
STATIC_HEADER,
NULL,
"flow_controlled",
sizeof(struct flow_controlled),
NULL,
NULL,
};
#endif /* !GABA_DECLARE */
/*
CLASS:write_buffer:abstract_write
*/
#ifndef GABA_DEFINE
struct write_buffer
{
struct abstract_write super;
struct lsh_fd *fd;
uint32_t block_size;
struct lsh_string *buffer;
int empty;
uint32_t length;
struct flow_controlled *report;
int closed;
struct string_queue q;
uint32_t pos;
struct lsh_string *partial;
uint32_t start;
uint32_t end;
};
extern struct lsh_class write_buffer_class;
#endif /* !GABA_DEFINE */
#ifndef GABA_DECLARE
static void
do_write_buffer_mark(struct lsh_object *o,
void (*mark)(struct lsh_object *o))
{
struct write_buffer *i = (struct write_buffer *) o;
mark((struct lsh_object *) i->fd);
mark((struct lsh_object *) i->report);
string_queue_mark(&(i->q),
mark);
}
static void
do_write_buffer_free(struct lsh_object *o)
{
struct write_buffer *i = (struct write_buffer *) o;
lsh_string_free(i->buffer);
string_queue_free(&(i->q));
lsh_string_free(i->partial);
}
struct lsh_class write_buffer_class =
{
STATIC_HEADER,
&(abstract_write_class),
"write_buffer",
sizeof(struct write_buffer),
do_write_buffer_mark,
do_write_buffer_free,
};
#endif /* !GABA_DECLARE */
|