If called at runtime, must be thread-safe */
| 292 | |
| 293 | /* If called at runtime, must be thread-safe */ |
| 294 | PxTaskID PxTaskMgr::submitNamedTask( PxTask *task, const char *name, PxTaskType::Enum type ) |
| 295 | { |
| 296 | if( task ) |
| 297 | { |
| 298 | task->mTm = this; |
| 299 | task->submitted(); |
| 300 | } |
| 301 | |
| 302 | LOCK(); |
| 303 | |
| 304 | const PxTaskNameToIDMap::Entry *ret = mName2IDmap.find( name ); |
| 305 | if( ret ) |
| 306 | { |
| 307 | PxTaskID prereg = ret->second; |
| 308 | if( task ) |
| 309 | { |
| 310 | /* name was registered for us by a dependent task */ |
| 311 | PX_ASSERT( !mTaskTable[ prereg ].mTask ); |
| 312 | PX_ASSERT( mTaskTable[ prereg ].mType == PxTaskType::TT_NOT_PRESENT ); |
| 313 | mTaskTable[ prereg ].mTask = task; |
| 314 | mTaskTable[ prereg ].mType = type; |
| 315 | task->mTaskID = prereg; |
| 316 | } |
| 317 | return prereg; |
| 318 | } |
| 319 | else |
| 320 | { |
| 321 | shdfnd::atomicIncrement(&mPendingTasks); |
| 322 | PxTaskID id = static_cast<PxTaskID>(mTaskTable.size()); |
| 323 | mName2IDmap[ name ] = id; |
| 324 | if( task ) |
| 325 | { |
| 326 | task->mTaskID = id; |
| 327 | } |
| 328 | PxTaskTableRow r; |
| 329 | r.mTask = task; |
| 330 | r.mType = type; |
| 331 | mTaskTable.pushBack(r); |
| 332 | return id; |
| 333 | } |
| 334 | } |
| 335 | |
| 336 | /* |
| 337 | * Add an unnamed task to the task table |
nothing calls this directly
no test coverage detected