Sha256: e04e8a4b1b486d5d5914e2165486775cd6343867f7c17bc518966c41344fc398

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

# frozen_string_literal: true

require_relative '../fuse_context'

module FFI
  module Libfuse
    module Adapter
      # Wrapper module to handle interrupts
      #
      # Include this module if you want all requests to check for interruption before processing
      #
      # To handle interrupts only for specific callbacks just call {Libfuse.raise_interrupt} or
      # {Libfuse.fuse_interrupted?} during callback processing rather than including this adapter
      module Interrupt
        # @!visibility private
        def fuse_wrappers(*wrappers)
          wrappers << {
            wrapper: proc { |_fuse_method, *args, &b| Interrupt.interrupt_callback(*args, &b) },
            excludes: %i[init destroy]
          }
          return wrappers unless defined?(super)

          super(*wrappers)
        end

        module_function

        # @raise [Errno::EINTR] if the fuse request is marked as interrupted
        def interrupt_callback(*args)
          return -Errno::EINTR::Errno if Libfuse.fuse_interrupted?

          yield(*args)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ffi-libfuse-0.1.0.rc20220550 lib/ffi/libfuse/adapter/interrupt.rb
ffi-libfuse-0.0.1.rctest12 lib/ffi/libfuse/adapter/interrupt.rb
ffi-libfuse-0.0.1.rctest11 lib/ffi/libfuse/adapter/interrupt.rb
ffi-libfuse-0.0.1.pre lib/ffi/libfuse/adapter/interrupt.rb