Showing the changes to src/core/chuck.cpp (1 of 42 files). Show all
Unified · Split
| @@ -90,7 +90,7 @@ · 89 unmodified lines | |||
| 90 | 90 | ||
| 91 | 91 | ||
| 92 | // chuck statics | 92 | // chuck statics |
| 93 | const char ChucK::VERSION[] = "1.4.0.0 (numchucks)"; | 93 | const char ChucK::VERSION[] = "1.4.0.1 (numchucks)"; |
| 94 | t_CKUINT ChucK::o_numVMs = 0; | 94 | t_CKUINT ChucK::o_numVMs = 0; |
| 95 | t_CKBOOL ChucK::o_isGlobalInit = FALSE; | 95 | t_CKBOOL ChucK::o_isGlobalInit = FALSE; |
| 96 | t_CKBOOL ChucK::enableSystemCall = FALSE; | 96 | t_CKBOOL ChucK::enableSystemCall = FALSE; |
| @@ -140,6 +140,8 @@ ChucK::ChucK() · 43 unmodified lines | |||
| 140 | initDefaultParams(); | 140 | initDefaultParams(); |
| 141 | // did user init? | 141 | // did user init? |
| 142 | m_init = FALSE; | 142 | m_init = FALSE; |
| 143 | // zero out the hook | ||
| 144 | m_hook = NULL; // m_hook = nullptr | ||
| 143 | 145 | ||
| 144 | // global init, if needed | 146 | // global init, if needed |
| 145 | if( !o_isGlobalInit ) globalInit(); | 147 | if( !o_isGlobalInit ) globalInit(); |
| @@ -684,22 +686,23 @@ bool ChucK::shutdown() · 538 unmodified lines | |||
| 684 | stk_detach( m_carrier ); | 686 | stk_detach( m_carrier ); |
| 685 | 687 | ||
| 686 | // cancel otf thread | 688 | // cancel otf thread |
| 687 | #ifndef __DISABLE_OTF_SERVER__ | 689 | if(m_carrier->otf_thread) |
| 690 | { | ||
| 688 | #if !defined(__PLATFORM_WIN32__) || defined(__WINDOWS_PTHREAD__) | 691 | #if !defined(__PLATFORM_WIN32__) || defined(__WINDOWS_PTHREAD__) |
| 689 | if( m_carrier->otf_thread ) pthread_cancel( m_carrier->otf_thread ); | 692 | pthread_cancel( m_carrier->otf_thread ); |
| 690 | #else | 693 | #else |
| 691 | if( m_carrier->otf_thread ) CloseHandle( m_carrier->otf_thread ); | 694 | CloseHandle( m_carrier->otf_thread ); // doesn't cancel thread |
| 692 | #endif | 695 | #endif |
| 696 | m_carrier->otf_thread = 0; // signals thread shutdown | ||
| 697 | } | ||
| 698 | |||
| 693 | // close otf socket | 699 | // close otf socket |
| 694 | if( m_carrier->otf_socket ) ck_close( m_carrier->otf_socket ); | 700 | if( m_carrier->otf_socket ) ck_close( m_carrier->otf_socket ); |
| 695 | 701 | ||
| 696 | // reset | 702 | // reset |
| 697 | m_carrier->otf_socket = NULL; | 703 | m_carrier->otf_socket = NULL; |
| 698 | m_carrier->otf_port = 0; | 704 | m_carrier->otf_port = 0; |
| 699 | m_carrier->otf_thread = 0; | ||
| 700 | 705 | ||
| 701 | #endif | ||
| 702 | |||
| 703 | // TODO: a different way to unlock? | 706 | // TODO: a different way to unlock? |
| 704 | // unlock all objects to delete chout, cherr | 707 | // unlock all objects to delete chout, cherr |
| 705 | Chuck_VM_Object::unlock_all(); | 708 | Chuck_VM_Object::unlock_all(); |
| @@ -1715,3 +1718,29 @@ void ChucK::poop() · 1009 unmodified lines | |||
| 1715 | ::uh(); | 1718 | ::uh(); |
| 1716 | #endif | 1719 | #endif |
| 1717 | } | 1720 | } |
| 1721 | |||
| 1722 | |||
| 1723 | |||
| 1724 | |||
| 1725 | //----------------------------------------------------------------------------- | ||
| 1726 | // name: setMainThreadHook() | ||
| 1727 | // desc: set a function pointer to call from the main thread loop | ||
| 1728 | // e.g., for graphics, MAUI, potentially from a chug-in | ||
| 1729 | //----------------------------------------------------------------------------- | ||
| 1730 | bool ChucK::setMainThreadHook(Chuck_DL_MainThreadHook * hook) | ||
| 1731 | { | ||
| 1732 | m_hook = hook; | ||
| 1733 | return true; | ||
| 1734 | } | ||
| 1735 | |||
| 1736 | |||
| 1737 | |||
| 1738 | |||
| 1739 | //----------------------------------------------------------------------------- | ||
| 1740 | // name: getMainThreadHook() | ||
| 1741 | // desc: get pointer to current function to be called from main loop | ||
| 1742 | //----------------------------------------------------------------------------- | ||
| 1743 | Chuck_DL_MainThreadHook * ChucK::getMainThreadHook() | ||
| 1744 | { | ||
| 1745 | return m_hook; | ||
| 1746 | } | ||