-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ refactor ] drive Async via an uv_async_t handle
- Loading branch information
1 parent
b200d31
commit 1801c63
Showing
6 changed files
with
82 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
module System.UV.Raw.Async | ||
|
||
import System.UV.Raw.Callback | ||
import System.UV.Raw.Handle | ||
import System.UV.Raw.Loop | ||
import System.UV.Raw.Pointer | ||
import System.UV.Raw.Util | ||
|
||
%default total | ||
|
||
-------------------------------------------------------------------------------- | ||
-- FFI | ||
-------------------------------------------------------------------------------- | ||
|
||
%foreign (idris_uv "uv_async_init") | ||
prim__uv_async_init : Ptr Loop -> Ptr Async -> AnyPtr -> PrimIO Int32 | ||
|
||
%foreign (idris_uv "uv_async_send") | ||
prim__uv_async_send : Ptr Async -> PrimIO Int32 | ||
|
||
-------------------------------------------------------------------------------- | ||
-- API | ||
-------------------------------------------------------------------------------- | ||
|
||
parameters {auto has : HasIO io} | ||
export | ||
uv_async_init : Ptr Loop -> Ptr Async -> (Ptr Async -> IO ()) -> io Int32 | ||
uv_async_init l h f = do | ||
cb <- ptrCB f | ||
uv_handle_set_data h cb | ||
primIO $ prim__uv_async_init l h cb | ||
|
||
export %inline | ||
uv_async_send : Ptr Async -> io Int32 | ||
uv_async_send p = primIO $ prim__uv_async_send p |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters