uv_stream_t* s; | |
uv_pipeline_t p1 = { | |
.alloc_cb = int(uv_stream_t* s, uv_pipeline_t*, size_t size, uv_buf_t* buf) { | |
}, | |
.read_cb = int(uv_stream_t* s, uv_pipeline_t* p, uv_buf_t* buf) { | |
// The point here is that you could call it in a later tick, thus | |
// the next pipeline couldn't be provided as an argument to this function | |
uv_pipeline_t* next = uv_stream_next_pipeline(s, &p); | |
next->alloc_cb(...); | |
next->read_cb(...); | |
}, | |
.write_cb = int(uv_stream_t* s, uv_pipeline_t*, uv_buf_t* bufs, unsigned int buf_cnt) { | |
next->write_cb(...); | |
}, | |
.shutdown_cb = int(uv_stream_t* s, uv_pipeline_t*) { | |
next->shutdown_cb(...); | |
}, | |
.close_cb = int(uv_stream_t* s, uv_pipeline_t*) { | |
next->close_cb(...); | |
} | |
}; | |
uv_pipeline_t p2 = { | |
.alloc_cb = ..., | |
.read_cb = ..., | |
.write_cb = ..., | |
// These could be NULL, meaning that this pipeline will affect only | |
// alloc/read/write | |
.shutdown_cb = NULL | |
.close_cb = NULL | |
}; | |
// Append new pipeline to the | |
uv_stream_pipeline(s, &p1); | |
uv_stream_pipeline_before(s, &p1, &p2); | |
// uv_stream_pipeline_after(s, &p1, &p2); |
This comment has been minimized.
This comment has been minimized.
piscisaureus
commented
Jun 27, 2014
@indutny Who calls read_cb, write_cb etc? And who calls alloc_cb? I would suggest to make a "filter" stream. The filter knows what it's upstream stream (or another filter) is. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This comment has been minimized.
indutny commentedJun 27, 2014
@saghul: let's iterate over it a bit and post on a mailing list to gather more feedback.