Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

Clarify API doc comments in uv.h

  • Loading branch information
bnoordhuis committed Feb 9, 2012
1 parent 4a5f3bb commit 62206c2db0ddd944cd0c447492da9b0de9c476a6
Showing with 18 additions and 5 deletions.
  1. +18 −5 include/uv.h
@@ -238,22 +238,35 @@ UV_EXTERN int64_t uv_now(uv_loop_t*);


/*
* The status parameter is 0 if the request completed successfully,
* and should be -1 if the request was cancelled or failed.
* Error details can be obtained by calling uv_last_error().
* Should return a buffer that libuv can use to read data into.
*
* In the case of uv_read_cb the uv_buf_t returned should be freed by the
* user.
* `suggested_size` is a hint. Returning a buffer that is smaller is perfectly
* okay as long as `buf.len > 0`.
*/
typedef uv_buf_t (*uv_alloc_cb)(uv_handle_t* handle, size_t suggested_size);

/*
* `nread` is > 0 if there is data available, 0 if libuv is done reading for now
* or -1 on error.
*
* Error details can be obtained by calling uv_last_error(). UV_EOF indicates
* that the stream has been closed.
*
* The callee is responsible for closing the stream when an error happens.
* Trying to read from the stream again is undefined.
*
* The callee is responsible for freeing the buffer, libuv does not reuse it.
*/
typedef void (*uv_read_cb)(uv_stream_t* stream, ssize_t nread, uv_buf_t buf);

/*
* Just like the uv_read_cb except that if the pending parameter is true
* then you can use uv_accept() to pull the new handle into the process.
* If no handle is pending then pending will be UV_UNKNOWN_HANDLE.
*/
typedef void (*uv_read2_cb)(uv_pipe_t* pipe, ssize_t nread, uv_buf_t buf,
uv_handle_type pending);

typedef void (*uv_write_cb)(uv_write_t* req, int status);
typedef void (*uv_connect_cb)(uv_connect_t* req, int status);
typedef void (*uv_shutdown_cb)(uv_shutdown_t* req, int status);

0 comments on commit 62206c2

Please sign in to comment.
You can’t perform that action at this time.