Class: Rufio::AsyncScannerFiberWrapper
- Inherits:
-
Object
- Object
- Rufio::AsyncScannerFiberWrapper
- Defined in:
- lib/rufio/async_scanner_fiber.rb
Overview
Fiber(Asyncライブラリ)統合用ラッパークラス
Asyncライブラリと統合し、ノンブロッキングで非同期スキャンを実行します。
使用例:
Async do
scanner = NativeScannerRubyCore.new
wrapper = AsyncScannerFiberWrapper.new(scanner)
entries = wrapper.scan_async('/path')
puts "Found #{entries.length} entries"
end
Instance Method Summary collapse
-
#cancel ⇒ Object
スキャンをキャンセル.
-
#get_progress ⇒ Hash
進捗を取得.
-
#get_state ⇒ Symbol
状態を取得.
-
#initialize(scanner) ⇒ AsyncScannerFiberWrapper
constructor
A new instance of AsyncScannerFiberWrapper.
-
#scan_async(path, timeout: nil) ⇒ Array<Hash>
非同期スキャンを開始し、Fiberで完了を待つ.
-
#scan_async_with_progress(path, timeout: nil) {|current, total| ... } ⇒ Array<Hash>
進捗報告付きスキャン.
-
#scan_fast_async(path, max_entries, timeout: nil) ⇒ Array<Hash>
高速スキャン(エントリ数制限付き).
Constructor Details
#initialize(scanner) ⇒ AsyncScannerFiberWrapper
Returns a new instance of AsyncScannerFiberWrapper.
24 25 26 |
# File 'lib/rufio/async_scanner_fiber.rb', line 24 def initialize(scanner) @scanner = scanner end |
Instance Method Details
#cancel ⇒ Object
スキャンをキャンセル
70 71 72 |
# File 'lib/rufio/async_scanner_fiber.rb', line 70 def cancel @scanner.cancel end |
#get_progress ⇒ Hash
進捗を取得
84 85 86 |
# File 'lib/rufio/async_scanner_fiber.rb', line 84 def get_progress @scanner.get_progress end |
#get_state ⇒ Symbol
状態を取得
77 78 79 |
# File 'lib/rufio/async_scanner_fiber.rb', line 77 def get_state @scanner.get_state end |
#scan_async(path, timeout: nil) ⇒ Array<Hash>
非同期スキャンを開始し、Fiberで完了を待つ
33 34 35 36 37 38 39 |
# File 'lib/rufio/async_scanner_fiber.rb', line 33 def scan_async(path, timeout: nil) # スキャンを開始 @scanner.scan_async(path) # Fiberでポーリング poll_until_complete(timeout: timeout) end |
#scan_async_with_progress(path, timeout: nil) {|current, total| ... } ⇒ Array<Hash>
進捗報告付きスキャン
61 62 63 64 65 66 67 |
# File 'lib/rufio/async_scanner_fiber.rb', line 61 def scan_async_with_progress(path, timeout: nil, &block) # スキャンを開始 @scanner.scan_async(path) # 進捗付きでポーリング poll_until_complete_with_progress(timeout: timeout, &block) end |
#scan_fast_async(path, max_entries, timeout: nil) ⇒ Array<Hash>
高速スキャン(エントリ数制限付き)
47 48 49 50 51 52 53 |
# File 'lib/rufio/async_scanner_fiber.rb', line 47 def scan_fast_async(path, max_entries, timeout: nil) # スキャンを開始 @scanner.scan_fast_async(path, max_entries) # Fiberでポーリング poll_until_complete(timeout: timeout) end |