Skip to content
This repository has been archived by the owner on Nov 6, 2022. It is now read-only.

Updated README.md #256

Closed
wants to merge 2 commits into from
Closed

Updated README.md #256

wants to merge 2 commits into from

Conversation

lberezy
Copy link
Contributor

@lberezy lberezy commented Jun 28, 2015

Included information and example on communicating data between thread local and callback scopes. This shows how http-parser can be used in a multi-threaded context.

Included information and example on communicating data between thread local and callback scopes. This shows how http-parser can be used in a multi-threaded context.
@@ -137,6 +137,47 @@ There are two types of callbacks:
Callbacks must return 0 on success. Returning a non-zero value indicates
error to the parser, making it exit immediately.

For cases where it is necessary to pass local information to/from a callback the `http_parser` object's `data` field can be used. An example of such a case is when using threads to handle a socket connection, parse a request, and then give a response over that socket. By instantiation of a thread-local struct containing relevant data (e.g. accepted socket, allocated memory for callbacks to write into, etc), a parser's callbacks are able to communicate data between the scope of the thread and the scope of the callback in a threadsafe manner. This allows http-parser to be used in multi-threaded contexts.

This comment was marked as off-topic.

@indutny
Copy link
Member

indutny commented Jun 29, 2015

LGTM, except one nit. cc @bnoordhuis because I'm pretty bad at english :(

@jasnell
Copy link
Member

jasnell commented Oct 26, 2015

LGTM

jasnell pushed a commit that referenced this pull request Oct 26, 2015
Included information and example on communicating data between
thread local and callback scopes. This shows how http-parser
can be used in a multi-threaded context.

Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Fedor Indutny <[email protected]>
PR-URL: #256
@jasnell
Copy link
Member

jasnell commented Oct 26, 2015

Landed in 483eca7

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants