Sha256: 2e4b647313aca4f950cf6ecf32230d2e68f8373203e1bd70442b96b9c9ce4d77
Contents?: true
Size: 615 Bytes
Versions: 15
Compression:
Stored size: 615 Bytes
Contents
# 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
Version data entries
15 entries across 15 versions & 1 rubygems