Module: FiberAudit::Runtime::SchedulerSnapshotCapture
- Defined in:
- lib/fiber_audit/runtime/scheduler_snapshot.rb
Overview
Captures immutable scheduler snapshot at the current point in time. This is called at operation start to provide immutable context.
Class Method Summary collapse
Class Method Details
.capture ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/fiber_audit/runtime/scheduler_snapshot.rb', line 70 def capture scheduler = Fiber.scheduler scheduler_present = !scheduler.nil? # Normalize Fiber#blocking? to Boolean fiber_blocking = begin current_fiber = Fiber.current if current_fiber.respond_to?(:blocking?) !current_fiber.blocking?.nil? else false end rescue StandardError false end # Query scheduler capabilities if present io_select_supported = nil process_wait_supported = nil address_resolve_supported = nil if scheduler_present io_select_supported = scheduler.respond_to?(:io_select) process_wait_supported = scheduler.respond_to?(:process_wait) address_resolve_supported = scheduler.respond_to?(:address_resolve) end SchedulerSnapshot.new( scheduler_present: scheduler_present, fiber_blocking: fiber_blocking, scheduler_io_select_supported: io_select_supported, scheduler_process_wait_supported: process_wait_supported, scheduler_address_resolve_supported: address_resolve_supported ) rescue StandardError # Fail open: return a safe default snapshot SchedulerSnapshot.new( scheduler_present: false, fiber_blocking: false ) end |