Files
news.gitea.happylizard.me/bin/gems/jekyll-4.4.1/lib/jekyll/utils/thread_event.rb
T
pizza2d1 4cee170d66
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 9s
Add bin and edit workflow
2026-09-16 13:11:16 -06:00

32 lines
615 B
Ruby

# frozen_string_literal: true
module Jekyll
module Utils
# Based on the pattern and code from
# https://emptysqua.re/blog/an-event-synchronization-primitive-for-ruby/
class ThreadEvent
attr_reader :flag
def initialize
@lock = Mutex.new
@cond = ConditionVariable.new
@flag = false
end
def set
@lock.synchronize do
yield if block_given?
@flag = true
@cond.broadcast
end
end
def wait
@lock.synchronize do
@cond.wait(@lock) unless @flag
end
end
end
end
end