/xbmc/visualizations/Vortex/angelscript/docs/manual/doc_addon_ctxmgr.html
http://github.com/xbmc/xbmc · HTML · 69 lines · 59 code · 9 blank · 1 comment · 0 complexity · 973cd1f77ec79ad721e85f53e3bc8654 MD5 · raw file
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
- <title>AngelScript: Context manager</title>
- <link href="tabs.css" rel="stylesheet" type="text/css">
- <link href="doxygen.css" rel="stylesheet" type="text/css">
- </head><body>
- <!-- Generated by Doxygen 1.5.9 -->
- <div class="contents">
- <h1><a class="anchor" name="doc_addon_ctxmgr">Context manager </a></h1><b>Path:</b> /sdk/add_on/contextmgr/<p>
- The <code>CContextMgr</code> is a class designed to aid the management of multiple simultaneous scripts executing in parallel. It supports both <a class="el" href="doc_adv_concurrent.html">concurrent script threads</a> and <a class="el" href="doc_adv_coroutine.html">co-routines</a>.<p>
- If the application doesn't need multiple contexts, i.e. all scripts that are executed always complete before the next script is executed, then this class is not necessary.<p>
- Multiple context managers can be used, for example when you have a group of scripts controlling ingame objects, and another group of scripts controlling GUI elements, then each of these groups may be managed by different context managers.<p>
- Observe, that the context manager class hasn't been designed for multithreading, so you need to be careful if your application needs to execute scripts from multiple threads.<p>
- <dl class="see" compact><dt><b>See also:</b></dt><dd>The samples <a class="el" href="doc_samples_concurrent.html">Concurrent scripts</a> and <a class="el" href="doc_samples_corout.html">Co-routines</a> for uses</dd></dl>
- <h2><a class="anchor" name="doc_addon_ctxmgr_1">
- Public C++ interface</a></h2>
- <div class="fragment"><pre class="fragment"><span class="keyword">class </span>CContextMgr
- {
- <span class="keyword">public</span>:
- CContextMgr();
- ~CContextMgr();
- <span class="comment">// Set the function that the manager will use to obtain the time in milliseconds.</span>
- <span class="keywordtype">void</span> SetGetTimeCallback(TIMEFUNC_t func);
- <span class="comment">// Registers the script function</span>
- <span class="comment">//</span>
- <span class="comment">// void sleep(uint milliseconds)</span>
- <span class="comment">//</span>
- <span class="comment">// The application must set the get time callback for this to work</span>
- <span class="keywordtype">void</span> RegisterThreadSupport(<a class="code" href="classas_i_script_engine.html" title="The engine interface.">asIScriptEngine</a> *engine);
- <span class="comment">// Registers the script functions</span>
- <span class="comment">//</span>
- <span class="comment">// void createCoRoutine(const string &in functionName, any @arg)</span>
- <span class="comment">// void yield()</span>
- <span class="keywordtype">void</span> RegisterCoRoutineSupport(<a class="code" href="classas_i_script_engine.html" title="The engine interface.">asIScriptEngine</a> *engine);
- <span class="comment">// Create a new context, prepare it with the function id, then return </span>
- <span class="comment">// it so that the application can pass the argument values. The context</span>
- <span class="comment">// will be released by the manager after the execution has completed.</span>
- <a class="code" href="classas_i_script_context.html" title="The interface to the virtual machine.">asIScriptContext</a> *AddContext(<a class="code" href="classas_i_script_engine.html" title="The engine interface.">asIScriptEngine</a> *engine, <span class="keywordtype">int</span> funcId);
- <span class="comment">// Create a new context, prepare it with the function id, then return</span>
- <span class="comment">// it so that the application can pass the argument values. The context</span>
- <span class="comment">// will be added as a co-routine in the same thread as the currCtx.</span>
- <a class="code" href="classas_i_script_context.html" title="The interface to the virtual machine.">asIScriptContext</a> *AddContextForCoRoutine(<a class="code" href="classas_i_script_context.html" title="The interface to the virtual machine.">asIScriptContext</a> *currCtx, <span class="keywordtype">int</span> funcId);
- <span class="comment">// Execute each script that is not currently sleeping. The function returns after </span>
- <span class="comment">// each script has been executed once. The application should call this function</span>
- <span class="comment">// for each iteration of the message pump, or game loop, or whatever.</span>
- <span class="keywordtype">void</span> ExecuteScripts();
- <span class="comment">// Put a script to sleep for a while</span>
- <span class="keywordtype">void</span> SetSleeping(<a class="code" href="classas_i_script_context.html" title="The interface to the virtual machine.">asIScriptContext</a> *ctx, <a class="code" href="angelscript_8h.html#c8186f029686800b7ce36bde4a55c815" title="32 bit unsigned integer">asUINT</a> milliSeconds);
- <span class="comment">// Switch the execution to the next co-routine in the group.</span>
- <span class="comment">// Returns true if the switch was successful.</span>
- <span class="keywordtype">void</span> NextCoRoutine();
- <span class="comment">// Abort all scripts</span>
- <span class="keywordtype">void</span> AbortAll();
- };
- </pre></div> </div>
- <hr size="1"><address style="text-align: right;"><small>Generated on Wed Dec 16 19:34:50 2009 for AngelScript by
- <a href="http://www.doxygen.org/index.html">
- <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address>
- </body>
- </html>