MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / postEvent

Function postEvent

Engine/source/console/simManager.cpp:94–137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

92// event post
93
94U32 postEvent(SimObject *destObject, SimEvent* event,U32 time)
95{
96 AssertFatal(time == -1 || time >= getCurrentTime(),
97 "Sim::postEvent() - Event time must be greater than or equal to the current time." );
98 AssertFatal(destObject, "Sim::postEvent() - Destination object for event doesn't exist.");
99
100 Mutex::lockMutex(gEventQueueMutex);
101
102 if( time == -1 ) // FIXME: a smart compiler will remove this check. - see http://garagegames.com/community/resources/view/19785 for a fix
103 time = gCurrentTime;
104
105 event->time = time;
106 event->startTime = gCurrentTime;
107 event->destObject = destObject;
108
109 if(!destObject)
110 {
111 delete event;
112
113 Mutex::unlockMutex(gEventQueueMutex);
114
115 return InvalidEventId;
116 }
117 event->sequenceCount = gEventSequence++;
118 SimEvent **walk = &gEventQueue;
119 SimEvent *current;
120
121 while((current = *walk) != NULL && (current->time < event->time))
122 walk = &(current->nextEvent);
123
124 // [tom, 6/24/2005] This ensures that SimEvents are dispatched in the same order that they are posted.
125 // This is needed to ensure Con::threadSafeExecute() executes script code in the correct order.
126 while((current = *walk) != NULL && (current->time == event->time))
127 walk = &(current->nextEvent);
128
129 event->nextEvent = current;
130 *walk = event;
131
132 U32 seqCount = event->sequenceCount;
133
134 Mutex::unlockMutex(gEventQueueMutex);
135
136 return seqCount;
137}
138
139//---------------------------------------------------------------------------
140// event cancellation

Callers

nothing calls this directly

Calls 1

getCurrentTimeFunction · 0.70

Tested by

no test coverage detected