MCPcopy Create free account
hub / github.com/cutdigital/mcut / get_event_info_impl

Function get_event_info_impl

source/frontend.cpp:509–595  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

507}
508
509void get_event_info_impl(
510 const McEvent event,
511 McFlags info,
512 McSize bytes,
513 McVoid* pMem,
514 McSize* pNumBytes)
515{
516 std::shared_ptr<event_t> event_ptr = g_events.find_first_if([=](const std::shared_ptr<event_t> ptr) { return ptr->m_user_handle == event; });
517
518 if (event_ptr == nullptr) {
519 throw std::invalid_argument("invalid event");
520 }
521
522 switch (info) {
523 case MC_EVENT_RUNTIME_EXECUTION_STATUS: {
524
525 if (pMem == nullptr) {
526 *pNumBytes = sizeof(McResult);
527 } else {
528 if (bytes < sizeof(McResult)) {
529 throw std::invalid_argument("invalid bytes");
530 }
531 McResult status = (McResult)event_ptr->m_runtime_exec_status.load();
532 memcpy(pMem, reinterpret_cast<McVoid*>(&status), bytes);
533 }
534 break;
535 }
536 case MC_EVENT_TIMESTAMP_SUBMIT:
537 case MC_EVENT_TIMESTAMP_START:
538 case MC_EVENT_TIMESTAMP_END: {
539 if (pMem == nullptr) {
540 *pNumBytes = sizeof(McSize);
541 } else {
542 if (bytes < sizeof(McSize)) {
543 throw std::invalid_argument("invalid bytes");
544 }
545 McSize nanoseconds_since_epoch = 0;
546 if (info == MC_EVENT_TIMESTAMP_SUBMIT) {
547 nanoseconds_since_epoch = event_ptr->m_timestamp_submit.load();
548 } else if (info == MC_EVENT_TIMESTAMP_START) {
549 nanoseconds_since_epoch = event_ptr->m_timestamp_start.load();
550 } else if (info == MC_EVENT_TIMESTAMP_END) {
551 nanoseconds_since_epoch = event_ptr->m_timestamp_end.load();
552 }
553 MCUT_ASSERT(nanoseconds_since_epoch != 0);
554 memcpy(pMem, reinterpret_cast<McVoid*>(&nanoseconds_since_epoch), bytes);
555 }
556 break;
557 }
558 case MC_EVENT_COMMAND_EXECUTION_STATUS: {
559 if (pMem == nullptr) {
560 *pNumBytes = sizeof(McEventCommandExecStatus);
561 } else {
562 if (bytes < sizeof(McEventCommandExecStatus)) {
563 throw std::invalid_argument("invalid bytes");
564 }
565 McEventCommandExecStatus status = (McEventCommandExecStatus)event_ptr->m_command_exec_status.load();
566 memcpy(pMem, reinterpret_cast<McVoid*>(&status), bytes);

Callers 1

mcGetEventInfoFunction · 0.85

Calls 1

find_first_ifMethod · 0.80

Tested by

no test coverage detected