|
|
| 59 |
} |
59 |
} |
| 60 |
}; |
60 |
}; |
| 61 |
|
61 |
|
|
|
62 |
class CheckSignalEventImpl : public ns3::EventImpl |
| 63 |
{ |
| 64 |
public: |
| 65 |
CheckSignalEventImpl () |
| 66 |
{ |
| 67 |
} |
| 68 |
virtual ~CheckSignalEventImpl () |
| 69 |
{ |
| 70 |
} |
| 71 |
virtual void Notify () |
| 72 |
{ |
| 73 |
PyGILState_STATE __py_gil_state; |
| 74 |
__py_gil_state = (PyEval_ThreadsInitialized() ? PyGILState_Ensure() : (PyGILState_STATE) 0); |
| 75 |
|
| 76 |
PyErr_CheckSignals(); |
| 77 |
if (PyErr_Occurred()) |
| 78 |
ns3::Simulator::Stop(); |
| 79 |
else |
| 80 |
ns3::Simulator::Schedule(ns3::Seconds(1), this); |
| 81 |
|
| 82 |
if (PyEval_ThreadsInitialized()) |
| 83 |
PyGILState_Release(__py_gil_state); |
| 84 |
} |
| 85 |
}; |
| 86 |
|
| 62 |
|
87 |
|
| 63 |
PyObject * |
88 |
PyObject * |
| 64 |
_wrap_Simulator_Schedule (PyNs3Simulator *PYBINDGEN_UNUSED (dummy), PyObject *args, PyObject *kwargs, |
89 |
_wrap_Simulator_Schedule (PyNs3Simulator *PYBINDGEN_UNUSED (dummy), PyObject *args, PyObject *kwargs, |
|
|
| 310 |
|
335 |
|
| 311 |
if (signal_check_frequency == -1) |
336 |
if (signal_check_frequency == -1) |
| 312 |
{ |
337 |
{ |
|
|
338 |
ns3::Ptr<CheckSignalEventImpl> py_event_impl = |
| 339 |
ns3::Create<CheckSignalEventImpl>(); |
| 313 |
if (PyEval_ThreadsInitialized ()) |
340 |
if (PyEval_ThreadsInitialized ()) |
| 314 |
py_thread_state = PyEval_SaveThread (); |
341 |
py_thread_state = PyEval_SaveThread (); |
|
|
342 |
ns3::Simulator::Schedule(ns3::Seconds(1), py_event_impl); |
| 315 |
ns3::Simulator::Run (); |
343 |
ns3::Simulator::Run (); |
| 316 |
if (py_thread_state) |
344 |
if (py_thread_state) |
| 317 |
PyEval_RestoreThread (py_thread_state); |
345 |
PyEval_RestoreThread (py_thread_state); |
|
|
346 |
if (PyErr_Occurred()) |
| 347 |
return NULL; |
| 318 |
} else { |
348 |
} else { |
| 319 |
while (!ns3::Simulator::IsFinished ()) |
349 |
while (!ns3::Simulator::IsFinished ()) |
| 320 |
{ |
350 |
{ |