Skip to content

Commit 8a79ec4

Browse files
authored
Merge pull request #2 from rm155/master
Improve Ractor-compliance
2 parents ff9e922 + a20f317 commit 8a79ec4

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/pstore.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,9 @@ def transaction(read_only = false) # :yields: pstore
602602
EMPTY_MARSHAL_DATA = Marshal.dump({})
603603
EMPTY_MARSHAL_CHECKSUM = CHECKSUM_ALGO.digest(EMPTY_MARSHAL_DATA)
604604

605+
EMPTY_MARSHAL_DATA.freeze
606+
EMPTY_MARSHAL_CHECKSUM.freeze
607+
605608
#
606609
# Open the specified filename (either in read-only mode or in
607610
# read-write mode) and lock it for reading or writing.
@@ -666,9 +669,12 @@ def load_data(file, read_only)
666669

667670
def on_windows?
668671
is_windows = RUBY_PLATFORM =~ /mswin|mingw|bccwin|wince/
669-
self.class.__send__(:define_method, :on_windows?) do
672+
673+
on_windows_proc = Proc.new do
670674
is_windows
671675
end
676+
Ractor.make_shareable(on_windows_proc) if defined?(Ractor)
677+
self.class.__send__(:define_method, :on_windows?, &on_windows_proc)
672678
is_windows
673679
end
674680

0 commit comments

Comments
 (0)