aboutsummaryrefslogtreecommitdiff
path: root/lib/std/event/future.zig
diff options
context:
space:
mode:
authorVexu <15308111+Vexu@users.noreply.github.com>2019-11-06 21:41:35 +0200
committerAndrew Kelley <andrew@ziglang.org>2019-11-06 15:17:40 -0500
commit4530adbd3314c28e2cfe831e7a20b154614e2c9c (patch)
tree3c2e31a1017db85db193e317c31007056e13c6d0 /lib/std/event/future.zig
parent913f7d045020f7f3301201cf69e1d788439d8886 (diff)
downloadzig-4530adbd3314c28e2cfe831e7a20b154614e2c9c.tar.gz
zig-4530adbd3314c28e2cfe831e7a20b154614e2c9c.zip
use global event loop in std.event types
Diffstat (limited to 'lib/std/event/future.zig')
-rw-r--r--lib/std/event/future.zig17
1 files changed, 5 insertions, 12 deletions
diff --git a/lib/std/event/future.zig b/lib/std/event/future.zig
index 3e5754982e..356d9cac79 100644
--- a/lib/std/event/future.zig
+++ b/lib/std/event/future.zig
@@ -3,7 +3,6 @@ const assert = std.debug.assert;
const testing = std.testing;
const builtin = @import("builtin");
const Lock = std.event.Lock;
-const Loop = std.event.Loop;
/// This is a value that starts out unavailable, until resolve() is called
/// While it is unavailable, functions suspend when they try to get() it,
@@ -23,9 +22,9 @@ pub fn Future(comptime T: type) type {
const Self = @This();
const Queue = std.atomic.Queue(anyframe);
- pub fn init(loop: *Loop) Self {
+ pub fn init() Self {
return Self{
- .lock = Lock.initLocked(loop),
+ .lock = Lock.initLocked(),
.available = 0,
.data = undefined,
};
@@ -90,17 +89,11 @@ test "std.event.Future" {
// TODO provide a way to run tests in evented I/O mode
if (!std.io.is_async) return error.SkipZigTest;
- var loop: Loop = undefined;
- try loop.initMultiThreaded();
- defer loop.deinit();
-
- const handle = async testFuture(&loop);
-
- loop.run();
+ const handle = async testFuture();
}
-fn testFuture(loop: *Loop) void {
- var future = Future(i32).init(loop);
+fn testFuture() void {
+ var future = Future(i32).init();
var a = async waitOnFuture(&future);
var b = async waitOnFuture(&future);