Skip to content

Commit

Permalink
Give cache mutex a more specific name
Browse files Browse the repository at this point in the history
  • Loading branch information
IAPark committed Apr 4, 2024
1 parent 186b0db commit 4ef55d6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/tiktoken_ruby/encoding.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class Tiktoken::Encoding
MUTEX = Mutex.new
CACHE_MUTEX = Mutex.new

attr_reader :name

Expand All @@ -17,7 +17,7 @@ def self.for_name(encoding)
# @param encoding [Symbol] The name of the encoding to load
# @return [Tiktoken::Encoding] The encoding instance
def self.for_name_cached(encoding)
MUTEX.synchronize do
CACHE_MUTEX.synchronize do
@encodings ||= {}
@encodings[encoding.to_sym] ||= Tiktoken::Encoding.for_name(encoding)
end
Expand Down

0 comments on commit 4ef55d6

Please sign in to comment.