|
547 | 547 | #
|
548 | 548 | # There is no such storage structure for write headers.
|
549 | 549 | #
|
| 550 | +# In order for the parsing methods to access stored converters in non-main-Ractors, the |
| 551 | +# storage structure must be made shareable first. |
| 552 | +# Therefore, <tt>Ractor.make_shareable(CSV::Converters)</tt> and |
| 553 | +# <tt>Ractor.make_shareable(CSV::HeaderConverters)</tt> must be called before the creation |
| 554 | +# of Ractors that use the converters stored in these structures. (Since making the storage |
| 555 | +# structures shareable involves freezing them, any custom converters that are to be used |
| 556 | +# must be added first.) |
| 557 | +# |
550 | 558 | # ===== Converter Lists
|
551 | 559 | #
|
552 | 560 | # A _converter_ _list_ is an \Array that may include any assortment of:
|
@@ -919,6 +927,7 @@ def initialize(message, line_number)
|
919 | 927 | gsub(/\s+/, "_").to_sym
|
920 | 928 | }
|
921 | 929 | }
|
| 930 | + |
922 | 931 | # Default values for method options.
|
923 | 932 | DEFAULT_OPTIONS = {
|
924 | 933 | # For both parsing and generating.
|
@@ -957,6 +966,8 @@ class << self
|
957 | 966 | # Creates or retrieves cached \CSV objects.
|
958 | 967 | # For arguments and options, see CSV.new.
|
959 | 968 | #
|
| 969 | + # This API is not Ractor-safe. |
| 970 | + # |
960 | 971 | # ---
|
961 | 972 | #
|
962 | 973 | # With no block given, returns a \CSV object.
|
@@ -1992,6 +2003,10 @@ def skip_lines
|
1992 | 2003 | # csv.converters # => [:integer]
|
1993 | 2004 | # csv.convert(proc {|x| x.to_s })
|
1994 | 2005 | # csv.converters
|
| 2006 | + # |
| 2007 | + # Notes that you need to call |
| 2008 | + # +Ractor.make_shareable(CSV::Converters)+ on the main Ractor to use |
| 2009 | + # this method. |
1995 | 2010 | def converters
|
1996 | 2011 | parser_fields_converter.map do |converter|
|
1997 | 2012 | name = Converters.rassoc(converter)
|
@@ -2054,6 +2069,10 @@ def write_headers?
|
2054 | 2069 | # Returns an \Array containing header converters; used for parsing;
|
2055 | 2070 | # see {Header Converters}[#class-CSV-label-Header+Converters]:
|
2056 | 2071 | # CSV.new('').header_converters # => []
|
| 2072 | + # |
| 2073 | + # Notes that you need to call |
| 2074 | + # +Ractor.make_shareable(CSV::HeaderConverters)+ on the main Ractor |
| 2075 | + # to use this method. |
2057 | 2076 | def header_converters
|
2058 | 2077 | header_fields_converter.map do |converter|
|
2059 | 2078 | name = HeaderConverters.rassoc(converter)
|
@@ -2774,6 +2793,8 @@ def writer_options
|
2774 | 2793 | # io = StringIO.new
|
2775 | 2794 | # CSV(io, col_sep: ";") { |csv| csv << ["a", "b", "c"] }
|
2776 | 2795 | #
|
| 2796 | +# This API is not Ractor-safe. |
| 2797 | +# |
2777 | 2798 | def CSV(*args, **options, &block)
|
2778 | 2799 | CSV.instance(*args, **options, &block)
|
2779 | 2800 | end
|
|
0 commit comments