- Joined
- Aug 6, 2011
- Messages
- 405
- Reaction score
- 2
- Points
- 18
For my simpit controller module I am writing, I have a method that checks a serial port for incoming data. This method is running as a separate thread. After processing any serial input, the following method may be called.
Line in question bolded:
Because the serial monitor is running in its own thread, the above method, and clbkPanelMouseEvent for a vessel, may be called at any time. So far this hasn't blown up or caused errors, but I may just be lucky.
Is it safe to call clbkPanelMouseEvent at any time? I was thinking about the consequences that might occur if the vessel's clbkPre(Post)Step was executing when clbkPanelMouseEvent is executed.
If it is unsafe to call clbkPanelMouseEvent at any time, I can queue events and call the vessel's clbkPanelMouseEvent within my module's clbkPreStep
Line in question bolded:
Code:
void PanelEventOutput::handleEvent(Event ev)
{
PanelMouseEvent toClick = userDefinitions[switches[ev.id].userDef][ev.state];
OBJHANDLE hSimVessel = oapiGetVesselByName(vesselName);
if (hSimVessel != NULL)
{
//vessel exists, so create the interface
VESSEL2 *simVessel = (VESSEL2 *)oapiGetVesselInterface(hSimVessel);
//and send the event!
[B]simVessel->clbkPanelMouseEvent(switches[ev.id].eventId,toClick.mouseEvent,toClick.mx,toClick.my);[/B]
}
}
Because the serial monitor is running in its own thread, the above method, and clbkPanelMouseEvent for a vessel, may be called at any time. So far this hasn't blown up or caused errors, but I may just be lucky.
Is it safe to call clbkPanelMouseEvent at any time? I was thinking about the consequences that might occur if the vessel's clbkPre(Post)Step was executing when clbkPanelMouseEvent is executed.
If it is unsafe to call clbkPanelMouseEvent at any time, I can queue events and call the vessel's clbkPanelMouseEvent within my module's clbkPreStep