Merge remote-tracking branch 'origin/master' into async-fs

This commit is contained in:
Andrew Kelley
2018-08-02 17:29:31 -04:00
25 changed files with 314 additions and 186 deletions

View File

@@ -354,11 +354,11 @@ pub const Loop = struct {
pub async fn linuxWaitFd(self: *Loop, fd: i32, flags: u32) !void {
defer self.linuxRemoveFd(fd);
suspend |p| {
suspend {
// TODO explicitly put this memory in the coroutine frame #1194
var resume_node = ResumeNode{
.id = ResumeNode.Id.Basic,
.handle = p,
.handle = @handle(),
};
try self.linuxAddFd(fd, &resume_node, flags);
}
@@ -449,12 +449,12 @@ pub const Loop = struct {
pub fn call(self: *Loop, comptime func: var, args: ...) !(promise->@typeOf(func).ReturnType) {
const S = struct {
async fn asyncFunc(loop: *Loop, handle: *promise->@typeOf(func).ReturnType, args2: ...) @typeOf(func).ReturnType {
suspend |p| {
handle.* = p;
suspend {
handle.* = @handle();
var my_tick_node = Loop.NextTickNode{
.prev = undefined,
.next = undefined,
.data = p,
.data = @handle(),
};
loop.onNextTick(&my_tick_node);
}
@@ -472,11 +472,11 @@ pub const Loop = struct {
/// CPU bound tasks would be waiting in the event loop but never get started because no async I/O
/// is performed.
pub async fn yield(self: *Loop) void {
suspend |p| {
suspend {
var my_tick_node = Loop.NextTickNode{
.prev = undefined,
.next = undefined,
.data = p,
.data = @handle(),
};
self.onNextTick(&my_tick_node);
}