PageRenderTime 22ms CodeModel.GetById 14ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/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
 1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 2<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
 3<title>AngelScript: Context manager</title>
 4<link href="tabs.css" rel="stylesheet" type="text/css">
 5<link href="doxygen.css" rel="stylesheet" type="text/css">
 6</head><body>
 7<!-- Generated by Doxygen 1.5.9 -->
 8<div class="contents">
 9<h1><a class="anchor" name="doc_addon_ctxmgr">Context manager </a></h1><b>Path:</b> /sdk/add_on/contextmgr/<p>
10The <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>
11If 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>
12Multiple 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>
13Observe, 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>
14<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>
15<h2><a class="anchor" name="doc_addon_ctxmgr_1">
16Public C++ interface</a></h2>
17<div class="fragment"><pre class="fragment"><span class="keyword">class </span>CContextMgr
18{
19<span class="keyword">public</span>:
20  CContextMgr();
21  ~CContextMgr();
22
23  <span class="comment">// Set the function that the manager will use to obtain the time in milliseconds.</span>
24  <span class="keywordtype">void</span> SetGetTimeCallback(TIMEFUNC_t func);
25
26  <span class="comment">// Registers the script function</span>
27  <span class="comment">//</span>
28  <span class="comment">//  void sleep(uint milliseconds)</span>
29  <span class="comment">//</span>
30  <span class="comment">// The application must set the get time callback for this to work</span>
31  <span class="keywordtype">void</span> RegisterThreadSupport(<a class="code" href="classas_i_script_engine.html" title="The engine interface.">asIScriptEngine</a> *engine);
32
33  <span class="comment">// Registers the script functions</span>
34  <span class="comment">//</span>
35  <span class="comment">//  void createCoRoutine(const string &amp;in functionName, any @arg)</span>
36  <span class="comment">//  void yield()</span>
37  <span class="keywordtype">void</span> RegisterCoRoutineSupport(<a class="code" href="classas_i_script_engine.html" title="The engine interface.">asIScriptEngine</a> *engine);
38
39  <span class="comment">// Create a new context, prepare it with the function id, then return </span>
40  <span class="comment">// it so that the application can pass the argument values. The context</span>
41  <span class="comment">// will be released by the manager after the execution has completed.</span>
42  <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);
43
44  <span class="comment">// Create a new context, prepare it with the function id, then return</span>
45  <span class="comment">// it so that the application can pass the argument values. The context</span>
46  <span class="comment">// will be added as a co-routine in the same thread as the currCtx.</span>
47  <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);
48
49  <span class="comment">// Execute each script that is not currently sleeping. The function returns after </span>
50  <span class="comment">// each script has been executed once. The application should call this function</span>
51  <span class="comment">// for each iteration of the message pump, or game loop, or whatever.</span>
52  <span class="keywordtype">void</span> ExecuteScripts();
53
54  <span class="comment">// Put a script to sleep for a while</span>
55  <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);
56
57  <span class="comment">// Switch the execution to the next co-routine in the group.</span>
58  <span class="comment">// Returns true if the switch was successful.</span>
59  <span class="keywordtype">void</span> NextCoRoutine();
60
61  <span class="comment">// Abort all scripts</span>
62  <span class="keywordtype">void</span> AbortAll();
63};
64</pre></div> </div>
65<hr size="1"><address style="text-align: right;"><small>Generated on Wed Dec 16 19:34:50 2009 for AngelScript by&nbsp;
66<a href="http://www.doxygen.org/index.html">
67<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address>
68</body>
69</html>