-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add prepare, check, idle and async handles, remove Net module where u…
…nnecessary
- Loading branch information
1 parent
7f6471c
commit af88df3
Showing
8 changed files
with
107 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module UV | ||
class Async | ||
include Handle, Resource, Listener | ||
|
||
def initialize(loop, &block) | ||
raise "no block given" unless block_given? | ||
@async_block = block | ||
end | ||
|
||
def send | ||
check_result UV.async_send(handle) | ||
end | ||
|
||
private | ||
def on_async(handle, status) | ||
@async_block.call(check_result(status)) | ||
end | ||
|
||
def create_handle | ||
ptr = UV.malloc(UV.handle_size(:uv_async)) | ||
check_result! UV.async_init(loop.pointer, ptr, callback(:on_async)) | ||
ptr | ||
end | ||
end | ||
end |
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,20 @@ | ||
module UV | ||
class Check | ||
include Handle, Resource, Listener | ||
|
||
def start(&block) | ||
raise "no block given" unless block_given? | ||
@check_block = block | ||
check_result! UV.check_start(handle, callback(:on_check)) | ||
end | ||
|
||
def stop | ||
check_result! UV.check_stop(handle) | ||
end | ||
|
||
private | ||
def on_check(handle, status) | ||
@check_block.call(check_result(status)) | ||
end | ||
end | ||
end |
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,20 @@ | ||
module UV | ||
class Idle | ||
include Handle, Resource, Listener | ||
|
||
def start(&block) | ||
raise "no block given" unless block_given? | ||
@idle_block = block | ||
check_result! UV.idle_start(handle, callback(:on_idle)) | ||
end | ||
|
||
def stop | ||
check_result! UV.idle_stop(handle) | ||
end | ||
|
||
private | ||
def on_idle(handle, status) | ||
@idle_block.call(check_result(status)) | ||
end | ||
end | ||
end |
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,20 @@ | ||
module UV | ||
class Prepare | ||
include Handle, Resource, Listener | ||
|
||
def start(&block) | ||
raise "no block given" unless block_given? | ||
@prepare_block = block | ||
check_result! UV.prepare_start(handle, callback(:on_prepare)) | ||
end | ||
|
||
def stop | ||
check_result! UV.prepare_stop(handle) | ||
end | ||
|
||
private | ||
def on_prepare(handle, status) | ||
@prepare_block.call(check_result(status)) | ||
end | ||
end | ||
end |
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