Ignore:
Timestamp:
Jan 9, 2021, 4:27:57 PM (10 months ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
arm-eh, jacob/cs343-translation, master, new-ast-unique-expr
Children:
561dd26
Parents:
35fd2c4
Message:

Added prints.
Naive implementation of cancel.
Server now shutdown cleanly.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/io/call.cfa.in

    r35fd2c4 rece0e80  
    464464
    465465print("""
     466//-----------------------------------------------------------------------------
     467bool cancel(io_cancellation & this) {
     468        #if !defined(CFA_HAVE_LINUX_IO_URING_H) || !defined(CFA_HAVE_IORING_OP_ASYNC_CANCEL)
     469                return false;
     470        #else
     471                io_future_t future;
     472
     473                io_context * context = __get_io_context();
     474
     475                __u8 sflags = 0;
     476                struct __io_data & ring = *context->thrd.ring;
     477
     478                __u32 idx;
     479                struct io_uring_sqe * sqe;
     480                [sqe, idx] = __submit_alloc( ring, (__u64)(uintptr_t)&future );
     481
     482                sqe->__pad2[0] = sqe->__pad2[1] = sqe->__pad2[2] = 0;
     483                sqe->opcode = IORING_OP_ASYNC_CANCEL;
     484                sqe->flags = sflags;
     485                sqe->addr = this.target;
     486
     487                verify( sqe->user_data == (__u64)(uintptr_t)&future );
     488                __submit( context, idx );
     489
     490                wait(future);
     491
     492                if( future.result == 0 ) return true; // Entry found
     493                if( future.result == -EALREADY) return true; // Entry found but in progress
     494                if( future.result == -ENOENT ) return false; // Entry not found
     495                return false;
     496        #endif
     497}
     498
    466499//-----------------------------------------------------------------------------
    467500// Check if a function is has asynchronous
Note: See TracChangeset for help on using the changeset viewer.