函数调用可以重新排序(Can function calls be reordered)
我正在使用C ++ 98。 函数调用可以在多大程度上被重新排序? 我没有使用任何全局状态,只有函数本地的对象状态。
我的具体情况是:
{ RaiiType T; Object1.FunctionCall(); Object2.FunctionCall(); }
Object1和Object2在下一个范围内声明。
T
的构造函数是否允许在两个函数调用之后重新排序,假设它可以被平凡地证明(至少对于人类而言)在构造函数调用和函数调用之间没有依赖关系?
在我的特殊情况下,RAII对象用于定时执行函数调用。
I am using C++98. To what extent can function calls be reordered? I am not using any global state, only state of objects local to the function.
My particular case is:
{ RaiiType T; Object1.FunctionCall(); Object2.FunctionCall(); }
Where Object1 and Object2 are declared in the next scope up. Is the constructor for
T
permitted to be reordered after either function call, assuming that it can be trivially proven (at least to a human) that there are no dependencies between the construction and the function calls?
In my particular case, the RAII object is used to time the execution of the function calls.
原文:https://stackoverflow.com/questions/30606924
最满意答案
为什么将wait_timeout设置为2147483
这是mysql2适配器的问题 !
mysql2_adapter使用相同的wait_timeout,但是直接将它传递给mysql,默认为更大的2592000 !!( 现在默认为2147483 )
# increase timeout so mysql server doesn't disconnect us wait_timeout = @config[:wait_timeout] wait_timeout = 2147483 unless wait_timeout.is_a?(Fixnum) variable_assignments << "@@wait_timeout = #{wait_timeout}" execute("SET #{variable_assignments.join(', ')}", :skip_logging)
Why does it set wait_timeout to 2147483
It's an issue with the mysql2 adapter!
mysql2_adapter uses this same wait_timeout, but passes it directly to mysql, and defaults to a much larger 2592000!!(Now it defaults to 2147483)
# increase timeout so mysql server doesn't disconnect us wait_timeout = @config[:wait_timeout] wait_timeout = 2147483 unless wait_timeout.is_a?(Fixnum) variable_assignments << "@@wait_timeout = #{wait_timeout}" execute("SET #{variable_assignments.join(', ')}", :skip_logging)
相关问答
更多-
为什么将wait_timeout设置为2147483 这是mysql2适配器的问题 ! mysql2_adapter使用相同的wait_timeout,但是直接将它传递给mysql,默认为更大的2592000 !!( 现在默认为2147483 ) # increase timeout so mysql server doesn't disconnect us wait_timeout = @config[:wait_timeout] wait_timeout = 2147483 unless wait_ti ...
-
来自MySQL文档: wait_timeout : 在线程启动时,根据客户端类型(由CLIENT_INTERACTIVE连接选项定义到mysql_real_connect()),会话wait_timeout值将从全局wait_timeout值或全局interactive_timeout值初始化。 另请参阅interactive_timeout。 您还应该降低ini文件中的interactive_timeout全局变量。 另请注意: 此超时仅适用于TCP / IP和Unix套接字文件连接,不适用于使用命名管道 ...
-
这是mysql2 gem页面的引用: 是啊...但为什么? 有人:Dude,Mysql宝石作品fiiiiiine。 我:确实如此,但它只是把你没有和字符串的字段值。 让你将它们转换成Ruby-land中的正确的Ruby类型 - 这是很慢的球。 有人:好的,但是do_mysql可以使用Ruby对象映射到MySQL类型的方式给我回值。 我:是的,但它的API比较复杂,可以慢两倍。 Here's a quote from the mysql2 gem page: Yeah… but why? Someone: D ...
-
答案是否定的 。 您不能将wait_timeout设置为无限制。 你可以参考MYSQL wait_timeout 但是,如果您想要更改它,那么您可以尝试这样: SET GLOBAL connect_timeout=....; The answer is NO. You can not set the wait_timeout to unlimited. You can refer MYSQL wait_timeout However if you want to change it then you ca ...
-
什么是mysql2?(What is mysql2?)[2024-02-01]
mysql2是mysql gem的现代继任者。 别担心,这对所有当前的MySQL版本都可以正常工作。 更多在这里: Ruby,Rails:mysql2宝石,有人使用这个宝石? 它稳定吗? mysql2 is the modern successor of the mysql gem. Don't worry, this will work fine for all current MySQL versions. More here: Ruby, Rails: mysql2 gem, does somebod ... -
是, 在MySQL中有2次超时。 哪一个用于连接取决于连接类型。 一个用于BATCH处理,另一个用于交互式 第二个变量是interactive_timeout。 看看interactive_timeout的设置 SHOW VARIABLES LIKE 'interactive_timeout'; SHOW GLOBAL VARIABLES LIKE 'interactive_timeout'; 通过mysql客户端登录样本 # mysql -uroot -p Enter password: Welcome ...
-
是的,你可以发出SQL SET GLOBAL max_allowed_packet=... 要更改max_allowed_packet的值,但由于它是全局变量 ,请注意必须重新连接才能使更改生效,因为更改全局系统变量不会影响当前打开的连接。 wait_timeout是一个正常的会话变量 ,您可以使用它轻松更改当前连接 SET SESSION wait_timeout=... Yes, you can issue the SQL SET GLOBAL max_allowed_packet=... to ...
-
wait_timeout和interactive_timeout都是连接断开之前不活动的时间。 因此,连接必须处于空闲状态(不运行查询)才能删除。 MySQL SLEEP()不计算,因为您正在运行查询。 您将不得不手动终止长时间运行的查询(没有设置让MySQL为您执行此操作)。 你可以编写脚本。 使用SHOW PROCESSLIST (或Innotop等外部工具)和KILL 。 Both wait_timeout and interactive_timeout is the time of inactivi ...
-
MySql:wait_timeout&“mysql server已经消失”错误信息(MySql : wait_timeout & “mysql server has gone away” error message)[2022-04-10]
MySQL服务器已经消失 - MySQL 5.5 链接 另一个 MySQL Server Has Gone Away - MySQL 5.5 link Another one -
Rails mysql2错误:“rake aborted!(Rails mysql2 error: “rake aborted! Please install the mysql2 adapter…”)[2022-06-12]
在rake db:create之前运行bundle install (在gem install mysql2 ) Run bundle install before rake db:create (after the gem install mysql2)