c++ - C++ 程序在 ODE 上超时
问题描述
我编写了一个在 coliru 和ideone上都超时的程序。
程序在多线程环境中调用call_once (): -- EDIT -- :源代码添加
**
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;
}
消息是:
Time limit exceeded #stdin #stdout 5s 4364KB
有没有办法增加这些ODE(在线开发环境)或任何其他 ODE的时间限制?
解决方案
因此,如果问题是要找到可以运行此代码的在线 IDE,请尝试查看 Online GDB。似乎运行良好:
https://onlinegdb.com/rydvS9pTM
在 MSVC 2015 等本地主机上也可以正常运行。
推荐阅读
- tfs - 防止 TFS 任务(工作项)被“解决”
- java - 用于验证文件格式的正则表达式
- postgresql - 恢复仅数据的 postesql 转储?
- launch - Cobalt 17.180626 调试版本 Ubuntu 16.04 无法加载视频
- javascript - Javascript:当文件名中有中文字符时抛出错误
- azure - 远程调试 azure
- php - 如何按降序显示数组中的键值?
- postgresql - 使用自定义 postgres 扩展时,外部数据库请求失败
- python - 使用 Python 将二维列表打印为多项式
- python - 没有这样的文件或目录:.../myapp-debug.apk