-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
119 additions
and
3 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
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
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,44 @@ | ||
/* | ||
Copyright 2017, orcaer@yeah.net All rights reserved. | ||
Author: orcaer@yeah.net | ||
Last modified: 2019-9-10 | ||
Description: uv-cpp | ||
*/ | ||
|
||
#include "Idle.h" | ||
|
||
using namespace uv; | ||
|
||
Idle::Idle(EventLoop* loop) | ||
:idle_(new uv_idle_t()) | ||
{ | ||
idle_->data = this; | ||
uv_idle_init(loop->hanlde(), idle_); | ||
uv_idle_start(idle_, idleCallback); | ||
} | ||
|
||
Idle::~Idle() | ||
{ | ||
uv_idle_stop(idle_); | ||
delete idle_; | ||
} | ||
|
||
void Idle::onCallback() | ||
{ | ||
if (callback_) | ||
callback_(); | ||
} | ||
|
||
void Idle::setCallback(DefaultCallback callback) | ||
{ | ||
callback_ = callback; | ||
} | ||
|
||
void Idle::idleCallback(uv_idle_t* handle) | ||
{ | ||
Idle* ptr = static_cast<Idle*>(handle->data); | ||
ptr->onCallback(); | ||
} |
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,38 @@ | ||
/* | ||
Copyright 2017, orcaer@yeah.net All rights reserved. | ||
Author: orcaer@yeah.net | ||
Last modified: 2019-9-11 | ||
Description: https://github.com/wlgq2/uv-cpp | ||
*/ | ||
|
||
#ifndef UV_IDLE_H | ||
#define UV_IDLE_H | ||
|
||
#include "EventLoop.h" | ||
|
||
namespace uv | ||
{ | ||
|
||
class Idle | ||
{ | ||
public: | ||
Idle(EventLoop* loop); | ||
virtual ~Idle(); | ||
|
||
void onCallback(); | ||
void setCallback(DefaultCallback callback); | ||
|
||
private: | ||
uv_idle_t* idle_; | ||
|
||
DefaultCallback callback_; | ||
|
||
private: | ||
static void idleCallback(uv_idle_t *handle); | ||
}; | ||
|
||
} | ||
#endif |
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