summaryrefslogtreecommitdiff
path: root/src/js_stream.cc
AgeCommit message (Collapse)Author
2015-03-06js_stream: fix leak of instancesFedor Indutny
Don't forget to call `MakeWeak` to ensure that instance objects are garbage collectable. PR-URL: https://github.com/iojs/io.js/pull/1078 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
2015-02-28stream_base: `.writev()` has limited supportFedor Indutny
Only TCP and JSStream do support `.writev()` on all platforms at the moment. Ensure that it won't be enabled everywhere. Fix: https://github.com/iojs/io.js/issues/995 PR-URL: https://github.com/iojs/io.js/pull/1008 Reviewed-by: Bert Belder <bertbelder@gmail.com> Reviewed-By: Rod Vagg <rod@vagg.org>
2015-02-25stream_base: remove static JSMethod declarationsFedor Indutny
Move JS methods to the stream_base-inl.h and thus define them on each use of `StreamBase::AddMethods`. Inline `AddMethods` itself, so that there won't be any need in a static declaration in stream_base.cc. NOTE: This basically allows using this API in user-land, though, some polishing is required before releasing it. PR-URL: https://github.com/iojs/io.js/pull/957 Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
2015-02-24streams: introduce StreamWrap and JSStreamFedor Indutny
Introduce a way to wrap plain-js `stream.Duplex` streams into C++ StreamBase's child class. With such method at hand it is now possible to pass `stream.Duplex` instance as a `socket` parameter to `tls.connect()`. PR-URL: https://github.com/iojs/io.js/pull/926 Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
2015-02-22stream_base: introduce StreamBaseFedor Indutny
StreamBase is an improved way to write C++ streams. The class itself is for separting `StreamWrap` (with the methods like `.writeAsciiString`, `.writeBuffer`, `.writev`, etc) from the `HandleWrap` class, making possible to write abstract C++ streams that are not bound to any uv socket. The following methods are important part of the abstraction (which mimics libuv's stream API): * Events: * `OnAlloc(size_t size, uv_buf_t*)` * `OnRead(ssize_t nread, const uv_buf_t*, uv_handle_type pending)` * `OnAfterWrite(WriteWrap*)` * Wrappers: * `DoShutdown(ShutdownWrap*)` * `DoTryWrite(uv_buf_t** bufs, size_t* count)` * `DoWrite(WriteWrap*, uv_buf_t*, size_t count, uv_stream_t* handle)` * `Error()` * `ClearError()` The implementation should provide all of these methods, thus providing the access to the underlying resource (be it uv handle, TLS socket, or anything else). A C++ stream may consume the input of another stream by replacing the event callbacks and proxying the writes. This kind of API is actually used now for the TLSWrap implementation, making it possible to wrap TLS stream into another TLS stream. Thus legacy API calls are no longer required in `_tls_wrap.js`. PR-URL: https://github.com/iojs/io.js/pull/840 Reviewed-By: Trevor Norris <trev.norris@gmail.com> Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>