Copyright | (c) Dong Han 2017-2018 |
---|---|
License | BSD |
Maintainer | winterland1989@gmail.com |
Stability | experimental |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell2010 |
This module provides UVStream
handle type.
Synopsis
- initUVStream :: HasCallStack => (Ptr UVLoop -> Ptr UVHandle -> IO ()) -> UVManager -> Resource UVStream
- data UVStream = UVStream {}
- getUVStreamFD :: HasCallStack => UVStream -> IO UVFD
- closeUVStream :: UVStream -> IO ()
- helloWorld :: UVStream -> IO ()
- echo :: UVStream -> IO ()
uv_stream abstraction
initUVStream :: HasCallStack => (Ptr UVLoop -> Ptr UVHandle -> IO ()) -> UVManager -> Resource UVStream Source #
Safely lock an uv manager and perform uv_handle initialization.
Initialization an UV stream usually take two step:
- allocate an uv_stream struct with proper size
- lock a particular uv_loop from a uv manager, and perform custom initialization, such as
uv_tcp_init
.
And this is what initUVStream
do, all you need to do is to provide the manager you want to hook the handle
onto(usually the one on the same capability, i.e. the one obtained by getUVManager
),
and provide a custom initialization function (which should throw an exception if failed).
A haskell data type wrap an uv_stream_t
inside
UVStream
DO NOT provide thread safety! Use UVStream
concurrently in multiple
threads will lead to undefined behavior.
getUVStreamFD :: HasCallStack => UVStream -> IO UVFD Source #
Get stream fd
closeUVStream :: UVStream -> IO () Source #
Manually close a uv stream.