| 640 | } |
| 641 | |
| 642 | void dispatch_impl( |
| 643 | McContext contextHandle, |
| 644 | McFlags dispatchFlags, |
| 645 | const McVoid* pSrcMeshVertices, |
| 646 | const uint32_t* pSrcMeshFaceIndices, |
| 647 | const uint32_t* pSrcMeshFaceSizes, |
| 648 | uint32_t numSrcMeshVertices, |
| 649 | uint32_t numSrcMeshFaces, |
| 650 | const McVoid* pCutMeshVertices, |
| 651 | const uint32_t* pCutMeshFaceIndices, |
| 652 | const uint32_t* pCutMeshFaceSizes, |
| 653 | uint32_t numCutMeshVertices, |
| 654 | uint32_t numCutMeshFaces, |
| 655 | uint32_t numEventsInWaitlist, |
| 656 | const McEvent* pEventWaitList, |
| 657 | McEvent* pEvent) |
| 658 | { |
| 659 | std::shared_ptr<context_t> context_ptr = g_contexts.find_first_if([=](const std::shared_ptr<context_t> cptr) { return cptr->m_user_handle == contextHandle; }); |
| 660 | |
| 661 | if (context_ptr == nullptr) { |
| 662 | throw std::invalid_argument("invalid context"); |
| 663 | } |
| 664 | |
| 665 | std::weak_ptr<context_t> context_weak_ptr(context_ptr); |
| 666 | |
| 667 | // submit the dispatch call to be executed asynchronously and return the future |
| 668 | // object that will be waited on as an event |
| 669 | const McEvent event_handle = context_ptr->prepare_and_submit_API_task( |
| 670 | MC_COMMAND_DISPATCH, numEventsInWaitlist, pEventWaitList, |
| 671 | [=]() { |
| 672 | if (!context_weak_ptr.expired()) { |
| 673 | std::shared_ptr<context_t> context = context_weak_ptr.lock(); |
| 674 | if (context) { |
| 675 | preproc( |
| 676 | context, |
| 677 | dispatchFlags, |
| 678 | pSrcMeshVertices, |
| 679 | pSrcMeshFaceIndices, |
| 680 | pSrcMeshFaceSizes, |
| 681 | numSrcMeshVertices, |
| 682 | numSrcMeshFaces, |
| 683 | pCutMeshVertices, |
| 684 | pCutMeshFaceIndices, |
| 685 | pCutMeshFaceSizes, |
| 686 | numCutMeshVertices, |
| 687 | numCutMeshFaces); |
| 688 | } |
| 689 | } |
| 690 | }); |
| 691 | |
| 692 | MCUT_ASSERT(pEvent != nullptr); |
| 693 | |
| 694 | *pEvent = event_handle; |
| 695 | } |
| 696 | |
| 697 | template <typename T> |
| 698 | T clamp(const T& n, const T& lower, const T& upper) |
no test coverage detected