Пример #1
0
func InitAio(size int) error {
	max_event_size = size
	cbs = make([]C.struct_iocb, max_event_size, max_event_size)
	aio_result_map = make([](chan aio_result), max_event_size, max_event_size)
	idle_event = make(chan uint, max_event_size)
	for i := 0; i < max_event_size; i++ {
		idle_event <- uint(i)
		retch := make(chan aio_result, 1)
		aio_result_map[i] = retch
	}
	pagesize = C.get_pagesize()
	aio_lock.Lock()
	ret := C.io_setup(C.int(max_event_size), &ctx)
	if int(ret) != 0 {
		aio_lock.Unlock()
		return errors.New("init aio failed")
	}
	aio_lock.Unlock()

	go run()

	return nil
}
Пример #2
0
func pagesize() int {
	return int(C.get_pagesize())
}