Skip to content

Commit 0062a2c

Browse files
committed
Rename RoleCtx to Ctx
1 parent bb87d4f commit 0062a2c

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

examples/pingpong.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub fn MkPingPong(
3434

3535
pub const info = pingpogn_info(client, &.{server});
3636

37-
pub fn process(parent_ctx: *info.RoleCtx(client)) !@This() {
37+
pub fn process(parent_ctx: *info.Ctx(client)) !@This() {
3838
const ctx = client_ctxFromParent(parent_ctx);
3939
if (ctx.client_counter >= 10) {
4040
ctx.client_counter = 0;
@@ -43,7 +43,7 @@ pub fn MkPingPong(
4343
return .{ .ping = .{ .data = ctx.client_counter } };
4444
}
4545

46-
pub fn preprocess_0(parent_ctx: *info.RoleCtx(server), msg: @This()) !void {
46+
pub fn preprocess_0(parent_ctx: *info.Ctx(server), msg: @This()) !void {
4747
const ctx = server_ctxFromParent(parent_ctx);
4848
switch (msg) {
4949
.ping => |val| ctx.server_counter = val.data,

examples/two_phase_commit_generic.zig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ pub fn mk2pc(
211211

212212
pub const info = two_pc(coordinator, &.{ alice, bob });
213213

214-
pub fn process(ctx: *info.RoleCtx(coordinator)) !@This() {
214+
pub fn process(ctx: *info.Ctx(coordinator)) !@This() {
215215
ctx.counter = 0;
216216
return .{ .begin = .{ .data = {} } };
217217
}
@@ -222,13 +222,13 @@ pub fn mk2pc(
222222

223223
pub const info = two_pc(alice, &.{coordinator});
224224

225-
pub fn process(ctx: *info.RoleCtx(alice)) !@This() {
225+
pub fn process(ctx: *info.Ctx(alice)) !@This() {
226226
const random: std.Random = ctx.xoshiro256.random();
227227
const res: bool = random.intRangeAtMost(u32, 0, 100) < 80;
228228
return .{ .resp = .{ .data = res } };
229229
}
230230

231-
pub fn preprocess_0(ctx: *info.RoleCtx(coordinator), msg: @This()) !void {
231+
pub fn preprocess_0(ctx: *info.Ctx(coordinator), msg: @This()) !void {
232232
switch (msg) {
233233
.resp => |val| {
234234
if (val.data) ctx.counter += 1;
@@ -243,13 +243,13 @@ pub fn mk2pc(
243243

244244
pub const info = two_pc(bob, &.{coordinator});
245245

246-
pub fn process(ctx: *info.RoleCtx(bob)) !@This() {
246+
pub fn process(ctx: *info.Ctx(bob)) !@This() {
247247
const random: std.Random = ctx.xoshiro256.random();
248248
const res: bool = random.intRangeAtMost(u32, 0, 100) < 80;
249249
return .{ .resp = .{ .data = res } };
250250
}
251251

252-
pub fn preprocess_0(ctx: *info.RoleCtx(coordinator), msg: @This()) !void {
252+
pub fn preprocess_0(ctx: *info.Ctx(coordinator), msg: @This()) !void {
253253
switch (msg) {
254254
.resp => |val| {
255255
if (val.data) ctx.counter += 1;
@@ -265,7 +265,7 @@ pub fn mk2pc(
265265

266266
pub const info = two_pc(coordinator, &.{ alice, bob });
267267

268-
pub fn process(ctx: *info.RoleCtx(coordinator)) !@This() {
268+
pub fn process(ctx: *info.Ctx(coordinator)) !@This() {
269269
if (ctx.counter == 2) {
270270
ctx.retry_times = 0;
271271
return .{ .succcessed = .{ .data = {} } };

src/root.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub fn ProtocolInfo(
3232
pub const internal_roles: []const Role_ = internal_roles_;
3333
pub const extern_state: []const type = extern_state_;
3434

35-
pub fn RoleCtx(_: @This(), r: Role_) type {
35+
pub fn Ctx(_: @This(), r: Role_) type {
3636
return @field(context_, @tagName(r));
3737
}
3838

@@ -356,7 +356,7 @@ pub fn Runner(
356356
comptime mult_channel_static_index_role: bool,
357357
mult_channel: anytype,
358358
curr_id: StateId,
359-
ctx: *State_.info.RoleCtx(curr_role),
359+
ctx: *State_.info.Ctx(curr_role),
360360
) !void {
361361
@setEvalBranchQuota(10_000_000);
362362
sw: switch (curr_id) {

0 commit comments

Comments
 (0)