fmt: fix alignment of struct init fields (#22025)

This commit is contained in:
yuyi 2024-08-11 14:11:24 +08:00 committed by GitHub
parent 99da5726db
commit c51d30bf53
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
671 changed files with 18817 additions and 18787 deletions

View file

@ -50,11 +50,11 @@ fn do_rec(ch chan int, id int, mut ctx Context) {
for {
for ch.try_pop(mut tmp) == .success {
ctx.pops[base + i] = Event{
is_set: true
id: id
gtime: time.sys_mono_now()
i: i
kind: .pop
is_set: true
id: id
gtime: time.sys_mono_now()
i: i
kind: .pop
elapsed: timer_sw_x.elapsed().nanoseconds()
}
timer_sw_x.restart()
@ -75,11 +75,11 @@ fn do_send(ch chan int, id int, mut ctx Context) {
for i := 0; i < n_iters; i++ {
idx := base + i
ctx.pushes[idx] = Event{
is_set: true
id: id
gtime: time.sys_mono_now()
i: i
kind: .push
is_set: true
id: id
gtime: time.sys_mono_now()
i: i
kind: .push
elapsed: timer_sw_x.elapsed().nanoseconds()
}
timer_sw_x.restart()
@ -106,13 +106,13 @@ fn main() {
max_number_of_pops := max_number_of_pushes * n_readers
eprintln('> max_number_of_pushes, ${max_number_of_pushes}, max_number_of_pops (per receiver), ${max_number_of_pops}')
mut ctx := &Context{
n_iters: n_iters
n_iters: n_iters
n_readers: n_readers
n_writers: n_writers
pushes_wg: sync.new_waitgroup()
pops_wg: sync.new_waitgroup()
pushes: []Event{len: max_number_of_pushes}
pops: []Event{len: max_number_of_pops}
pops_wg: sync.new_waitgroup()
pushes: []Event{len: max_number_of_pushes}
pops: []Event{len: max_number_of_pops}
}
ctx.pops_wg.add(n_readers)
for i := 0; i < n_readers; i++ {

View file

@ -71,14 +71,14 @@ fn new_channel_st(n u32, st u32) &Channel {
rbuf := if n > 0 { unsafe { malloc(int(n * st)) } } else { &u8(0) }
sbuf := if n > 0 { vcalloc_noscan(int(n * 2)) } else { &u8(0) }
mut ch := Channel{
objsize: st
cap: n
write_free: n
read_avail: 0
ringbuf: rbuf
statusbuf: sbuf
objsize: st
cap: n
write_free: n
read_avail: 0
ringbuf: rbuf
statusbuf: sbuf
write_subscriber: unsafe { nil }
read_subscriber: unsafe { nil }
read_subscriber: unsafe { nil }
}
ch.writesem.init(wsem)
ch.readsem.init(rsem)
@ -94,14 +94,14 @@ fn new_channel_st_noscan(n u32, st u32) &Channel {
rbuf := if n > 0 { unsafe { malloc_noscan(int(n * st)) } } else { &u8(0) }
sbuf := if n > 0 { vcalloc_noscan(int(n * 2)) } else { &u8(0) }
mut ch := Channel{
objsize: st
cap: n
write_free: n
read_avail: 0
ringbuf: rbuf
statusbuf: sbuf
objsize: st
cap: n
write_free: n
read_avail: 0
ringbuf: rbuf
statusbuf: sbuf
write_subscriber: unsafe { nil }
read_subscriber: unsafe { nil }
read_subscriber: unsafe { nil }
}
ch.writesem.init(wsem)
ch.readsem.init(rsem)

View file

@ -51,13 +51,13 @@ pub fn new_pool_processor(context PoolProcessorConfig) &PoolProcessor {
panic('You need to pass a valid callback to new_pool_processor.')
}
mut pool := PoolProcessor{
items: []
results: []
shared_context: unsafe { nil }
items: []
results: []
shared_context: unsafe { nil }
thread_contexts: []
njobs: context.maxjobs
ntask: 0
thread_cb: voidptr(context.callback)
njobs: context.maxjobs
ntask: 0
thread_cb: voidptr(context.callback)
}
pool.waitgroup.init()
return &pool

View file

@ -26,7 +26,7 @@ fn worker_i(mut p pool.PoolProcessor, idx int, worker_id int) &IResult {
fn test_work_on_strings() {
mut pool_s := pool.new_pool_processor(
callback: worker_s
maxjobs: 8
maxjobs: 8
)
pool_s.work_on_items(['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'])