History

Merge branch 'main' into emscripten-and-ios

Jack Atherton committed 5 years ago

Commit 8da8c8b2 parents a303f34 f524ce142 files · +13346 −6064Browse files

Showing the changes to src/core/chuck.cpp (1 of 42 files). Show all

Unified · Split

src/core/chuck.cpp+36−7
@@ -90,7 +90,7 @@ · 89 unmodified lines
9090
9191
9292 // chuck statics
93−const char ChucK::VERSION[] = "1.4.0.0 (numchucks)";
93+const char ChucK::VERSION[] = "1.4.0.1 (numchucks)";
9494 t_CKUINT ChucK::o_numVMs = 0;
9595 t_CKBOOL ChucK::o_isGlobalInit = FALSE;
9696 t_CKBOOL ChucK::enableSystemCall = FALSE;
@@ -140,6 +140,8 @@ ChucK::ChucK() · 43 unmodified lines
140140 initDefaultParams();
141141 // did user init?
142142 m_init = FALSE;
143+ // zero out the hook
144+ m_hook = NULL; // m_hook = nullptr
143145
144146 // global init, if needed
145147 if( !o_isGlobalInit ) globalInit();
@@ -684,22 +686,23 @@ bool ChucK::shutdown() · 538 unmodified lines
684686 stk_detach( m_carrier );
685687
686688 // cancel otf thread
687−#ifndef __DISABLE_OTF_SERVER__
689+ if(m_carrier->otf_thread)
690+ {
688691 #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 );
690693 #else
691− if( m_carrier->otf_thread ) CloseHandle( m_carrier->otf_thread );
694+ CloseHandle( m_carrier->otf_thread ); // doesn't cancel thread
692695 #endif
696+ m_carrier->otf_thread = 0; // signals thread shutdown
697+ }
698+
693699 // close otf socket
694700 if( m_carrier->otf_socket ) ck_close( m_carrier->otf_socket );
695701
696702 // reset
697703 m_carrier->otf_socket = NULL;
698704 m_carrier->otf_port = 0;
699− m_carrier->otf_thread = 0;
700705
701−#endif
702−
703706 // TODO: a different way to unlock?
704707 // unlock all objects to delete chout, cherr
705708 Chuck_VM_Object::unlock_all();
@@ -1715,3 +1718,29 @@ void ChucK::poop() · 1009 unmodified lines
17151718 ::uh();
17161719 #endif
17171720 }
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+}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t