Я написал программу, которая работает как на колиру, так и на ideone .
Программа вызывает call_once () в многопоточной среде:
- РЕДАКТИРОВАТЬ -: добавлен исходный код
**
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?