mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 07:03:29 +00:00
async: remove @This from SigleThreaded
This commit is contained in:
@@ -64,10 +64,9 @@ pub const SingleThreaded = struct {
|
|||||||
cbk: Cbk,
|
cbk: Cbk,
|
||||||
ctx: *Ctx,
|
ctx: *Ctx,
|
||||||
|
|
||||||
const Self = @This();
|
|
||||||
const Cbk = *const fn (ctx: *Ctx, res: anyerror!void) anyerror!void;
|
const Cbk = *const fn (ctx: *Ctx, res: anyerror!void) anyerror!void;
|
||||||
|
|
||||||
pub fn init(loop: *Loop) Self {
|
pub fn init(loop: *Loop) SingleThreaded {
|
||||||
return .{
|
return .{
|
||||||
.impl = NetworkImpl.init(loop),
|
.impl = NetworkImpl.init(loop),
|
||||||
.cbk = undefined,
|
.cbk = undefined,
|
||||||
@@ -76,7 +75,7 @@ pub const SingleThreaded = struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn connect(
|
pub fn connect(
|
||||||
self: *Self,
|
self: *SingleThreaded,
|
||||||
comptime _: type,
|
comptime _: type,
|
||||||
ctx: *Ctx,
|
ctx: *Ctx,
|
||||||
comptime cbk: Cbk,
|
comptime cbk: Cbk,
|
||||||
@@ -88,13 +87,13 @@ pub const SingleThreaded = struct {
|
|||||||
self.impl.connect(self, socket, address);
|
self.impl.connect(self, socket, address);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn onConnect(self: *Self, err: ?anyerror) void {
|
pub fn onConnect(self: *SingleThreaded, err: ?anyerror) void {
|
||||||
if (err) |e| return self.ctx.setErr(e);
|
if (err) |e| return self.ctx.setErr(e);
|
||||||
self.cbk(self.ctx, {}) catch |e| self.ctx.setErr(e);
|
self.cbk(self.ctx, {}) catch |e| self.ctx.setErr(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn send(
|
pub fn send(
|
||||||
self: *Self,
|
self: *SingleThreaded,
|
||||||
comptime _: type,
|
comptime _: type,
|
||||||
ctx: *Ctx,
|
ctx: *Ctx,
|
||||||
comptime cbk: Cbk,
|
comptime cbk: Cbk,
|
||||||
@@ -106,14 +105,14 @@ pub const SingleThreaded = struct {
|
|||||||
self.impl.send(self, socket, buf);
|
self.impl.send(self, socket, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn onSend(self: *Self, ln: usize, err: ?anyerror) void {
|
pub fn onSend(self: *SingleThreaded, ln: usize, err: ?anyerror) void {
|
||||||
if (err) |e| return self.ctx.setErr(e);
|
if (err) |e| return self.ctx.setErr(e);
|
||||||
self.ctx.setLen(ln);
|
self.ctx.setLen(ln);
|
||||||
self.cbk(self.ctx, {}) catch |e| self.ctx.setErr(e);
|
self.cbk(self.ctx, {}) catch |e| self.ctx.setErr(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn recv(
|
pub fn recv(
|
||||||
self: *Self,
|
self: *SingleThreaded,
|
||||||
comptime _: type,
|
comptime _: type,
|
||||||
ctx: *Ctx,
|
ctx: *Ctx,
|
||||||
comptime cbk: Cbk,
|
comptime cbk: Cbk,
|
||||||
@@ -125,7 +124,7 @@ pub const SingleThreaded = struct {
|
|||||||
self.impl.receive(self, socket, buf);
|
self.impl.receive(self, socket, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn onReceive(self: *Self, ln: usize, err: ?anyerror) void {
|
pub fn onReceive(self: *SingleThreaded, ln: usize, err: ?anyerror) void {
|
||||||
if (err) |e| return self.ctx.setErr(e);
|
if (err) |e| return self.ctx.setErr(e);
|
||||||
self.ctx.setLen(ln);
|
self.ctx.setLen(ln);
|
||||||
self.cbk(self.ctx, {}) catch |e| self.ctx.setErr(e);
|
self.cbk(self.ctx, {}) catch |e| self.ctx.setErr(e);
|
||||||
|
|||||||
Reference in New Issue
Block a user