Date: Friday, January 19, 2007 @ 12:35:36
  Author: marc
    Path: /cvsroot/carob/carob

Modified: include/JavaSocket.hpp (1.40 -> 1.41) include/StringCodecs.hpp
          (1.22 -> 1.23) src/StringCodecs.cpp (1.16 -> 1.17)

encode() and decode() methods are now always "const" thanks to a mutable 
CriticalSection
Holding+releasing a lock is not considered as a side-effect. CAROB-79.


--------------------------+
 include/JavaSocket.hpp   |    3 +--
 include/StringCodecs.hpp |    9 ++++-----
 src/StringCodecs.cpp     |    4 ++--
 3 files changed, 7 insertions(+), 9 deletions(-)


Index: carob/include/JavaSocket.hpp
diff -u carob/include/JavaSocket.hpp:1.40 carob/include/JavaSocket.hpp:1.41
--- carob/include/JavaSocket.hpp:1.40   Wed Jan 17 17:25:45 2007
+++ carob/include/JavaSocket.hpp        Fri Jan 19 12:35:36 2007
@@ -228,8 +228,7 @@
 
 private:
 #ifdef CAROB_USE_ICONV
-  // needs to be mutable because of locking
-  mutable CarobNS::IconvCodec utf8_codec;
+  const CarobNS::IconvCodec utf8_codec;
 #else
   const CarobNS::MBSCodec utf8_codec;
 #endif
Index: carob/include/StringCodecs.hpp
diff -u carob/include/StringCodecs.hpp:1.22 carob/include/StringCodecs.hpp:1.23
--- carob/include/StringCodecs.hpp:1.22 Thu Jan 18 15:04:31 2007
+++ carob/include/StringCodecs.hpp      Fri Jan 19 12:35:36 2007
@@ -141,14 +141,14 @@
    * @param w the wstring.
    * @return a string.
    */
-  std::string encode(const std::wstring&) throw (CodecException);
+  std::string encode(const std::wstring&) const throw (CodecException);
 
   /**
    * Decode from string to wstring.
    * @param s the string.
    * @return a wstring.
    */
-  std::wstring decode(const std::string&) throw (CodecException);
+  std::wstring decode(const std::string&) const throw (CodecException);
 
 private:
   /**
@@ -156,7 +156,7 @@
    */
   iconv_t cd_from, cd_to;
   /** iconv descriptors are stateful/not thread-safe */
-  CriticalSection iconvDecodeCS, iconvEncodeCS;
+  mutable CriticalSection iconvDecodeCS, iconvEncodeCS;
 };
 #endif // CAROB_USE_ICONV
 
@@ -193,8 +193,7 @@
   static const CarobNS::MBSCodec ascii_codec;
   /** Codec for UTF-8 strings */
 #ifdef CAROB_USE_ICONV
-  // iconv is stateful/not thread-safe: such codecs can't be "const"
-  static CarobNS::IconvCodec utf8_codec;
+  static const CarobNS::IconvCodec utf8_codec;
 #else
   static const CarobNS::MBSCodec utf8_codec;
 #endif
Index: carob/src/StringCodecs.cpp
diff -u carob/src/StringCodecs.cpp:1.16 carob/src/StringCodecs.cpp:1.17
--- carob/src/StringCodecs.cpp:1.16     Tue Jan 16 19:13:16 2007
+++ carob/src/StringCodecs.cpp  Fri Jan 19 12:35:36 2007
@@ -195,7 +195,7 @@
 }
 
 std::wstring
-IconvCodec::decode(const std::string &s) throw (CodecException)
+IconvCodec::decode(const std::string &s) const throw (CodecException)
 {
   if (s.empty())
     return std::wstring();
@@ -244,7 +244,7 @@
 }
 
 std::string
-IconvCodec::encode(const std::wstring &w) throw (CodecException)
+IconvCodec::encode(const std::wstring &w) const throw (CodecException)
 {
   if (w.empty())
     return std::string();

_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits

Reply via email to