C++ C++;程序在ODE上超时

C++ C++;程序在ODE上超时,c++,multithreading,ide,C++,Multithreading,Ide,我写了一个程序,在coliru和上都超时 程序在多线程环境中调用一次 --编辑-:添加源代码 ** call_once_xcp.cpp Demonstrate that if the first call to the call_once() function is unsuccessful, it will invoke a subsequent functionality. **/ #include <mutex> /// once_

我写了一个程序,在coliru和上都超时

程序在多线程环境中调用一次 --编辑-:添加源代码

** 
    call_once_xcp.cpp

    Demonstrate that if the first call to the call_once() function
    is unsuccessful, it will invoke a subsequent functionality.

**/

#include <mutex>        /// once_flag, call_once()
#include <thread>       /// thread
#include <exception>        /// runtime_error
#include <iostream>     /// cout

using namespace std;

once_flag of;

/// declarations ...
void func_call_xcp();   /// will call func_xcp()
void func_xcp();    /// will throw
void func_call_OK();    /// will call func_OK()
void func_OK();     /// won't throw


int main()
{
   thread t1 {func_call_xcp};
   t1.join();

   thread t2 {func_call_OK};
   t2.join();

   thread t3 {func_call_OK};
   t3.join();
}


/// will call func_xcp()
void func_call_xcp()
{
   try
   {
      call_once(of, func_xcp);
   }
   catch (exception& e)
   {
      cout << "exception: " << e.what()
           << endl;
   }
}


/// will call func_OK()
void func_call_OK()
{
   call_once(of, func_OK);
}


void func_xcp()     /// will throw
{
   cout << "** func_xcp()" << endl;

   throw runtime_error 
       {"error in func_xcp()"};
}


void func_OK()      /// won't throw
{
   cout << "** func_OK()" << endl;
}

有没有办法增加这些ODE(在线开发环境)或任何其他ODE的时间限制?

因此,如果问题是找到一个运行此代码的在线IDE,请尝试查看在线GDB。似乎运行得很好:


在MSVC 2015等本地主机上也可以正常运行。

而不是盲目增加时间。。而是找出是什么导致了这种情况timeout@B001,答案很简单。我不确定它的速度是否可以提高。我来这里是为了一个普通的微分方程:(*无论如何,我不明白
call\u once
与一个timeoutPlaying有什么关系,很明显,超时是因为异常处理而发生的,而不是call\u once()就其本身而言。我不确定ideone上GCC上使用的标志是什么,但如果它不使用优化,可以想象,解开STL的模板混乱会很沉重,@SSteven
more options
链接
Run
按钮左侧。它会打开
enter input
字段下的时间限制选项,因为本地主机可以正常工作那里没有时间限制。似乎ONLINE GDB没有任何时间限制,或者时间限制更宽泛。
Time limit exceeded #stdin #stdout 5s 4364KB