-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from instructure/2024-06-05
6.0.0
- Loading branch information
Showing
8 changed files
with
169 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'timeout' | ||
|
||
module FFMPEG | ||
# The Timeout class is a simple wrapper around the Timeout module that | ||
# provides a more convenient API to handle timeouts in a loop. | ||
class Timeout | ||
def self.start(duration, message = nil) | ||
new(duration, message) | ||
end | ||
|
||
def pause | ||
@paused = true | ||
end | ||
|
||
def resume | ||
@paused = false | ||
end | ||
|
||
def tick | ||
@last_tick = Time.now | ||
end | ||
|
||
def cancel | ||
return if @wait_thread.nil? | ||
|
||
@wait_thread.kill | ||
@wait_thread.join | ||
end | ||
|
||
private | ||
|
||
def initialize(duration, message = nil) | ||
@duration = duration | ||
@message = message | ||
|
||
@last_tick = Time.now | ||
@current_thread = Thread.current | ||
@wait_thread = Thread.new { loop } | ||
@paused = false | ||
end | ||
|
||
def loop | ||
if !@paused && Time.now - @last_tick >= @duration | ||
@current_thread.raise(::Timeout::Error, @message || self.class.name) | ||
else | ||
sleep 0.1 | ||
loop | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module FFMPEG | ||
VERSION = '5.0.1' | ||
VERSION = '6.0.0' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.