Difference between revisions of "CXTask"

From cxwiki

(Created page with "<div class="mw-parser-output">The CXTask class provides a mechanism for applications to request regular updates in a non-threaded manner. The application derives from CXT...")
 
Line 1: Line 1:
<div class="mw-parser-output">The CXTask class provides a mechanism for applications to request regular updates in a non-threaded manner.&nbsp;The application derives from CXTask and provides&nbsp;a CXTask::Idle() override which is called once per task update. Each CXTask must be registered with a&nbsp;CXTaskHost in order to receive updates. Updates occur whenever the&nbsp;CXTaskHost::IdleTasks() function is called.</div> <div class="mw-parser-output">&nbsp;</div>  
+
<div class="mw-parser-output"><div class="mw-parser-output">The CXTask class provides a mechanism for applications to request regular updates in a non-threaded manner.&nbsp;The application derives from CXTask and provides&nbsp;a CXTask::Idle() override which is called once per task update. Each CXTask must be registered with a&nbsp;CXTaskHost in order to receive updates.</div> <div class="mw-parser-output">&nbsp;</div> <div class="mw-parser-output">Updates occur whenever the&nbsp;CXTaskHost::IdleTasks() function is called, which (with the exception of the main thread task host in an application) is NOT automatic.</div> <div class="mw-parser-output">&nbsp;</div>  
= Main Thread Task Host =
+
= Thread Task Hosts =
<div class="mw-parser-output">&nbsp;</div> <div class="mw-parser-output">&nbsp;</div>  
+
 
= Background Thread Task Hosts =
+
Each thread may have a singleton CXTaskHost object. This object is created via CXTaskHost::InitCurrentThreadTaskHost(), accessed via CXTasskHost::GetCurrentThreadTaskHost(), and finally destroyed via CXTaskHost::KillCurrentThreadTaskHost(). The thread may trigger a task update by calling CXTaskHost::GetCurrentThreadTaskHost().IdleTasks().
<div class="mw-parser-output">&nbsp;</div> <div class="mw-parser-output">&nbsp;</div>  
+
 
 +
== Main Thread Task Host ==
 +
<div class="mw-parser-output">The main thread task host is created automatically during cxsource initialisation, and is destroyed automatically during cxsource shutdown. In a standard event-driven application, the main thread task host is updated on a regular basis via&nbsp;the main&nbsp;event loop. In other processes, such as a command-line tool, the application must explicitly update the main thread task host on a regular basis.</div>  
 +
== Background Thread Task Hosts ==
 +
<div class="mw-parser-output">Background threads do not automatically receive task hosts. If they will use task host functionality, they must explicitly create, update, and destroy the thread task host as required.</div>  
 
= Additional Task Hosts =
 
= Additional Task Hosts =
<div class="mw-parser-output">&nbsp;</div> <div class="mw-parser-output">&nbsp;</div>
+
<div class="mw-parser-output">It is also possible to create arbitrary task hosts, and update them on a custom schedule.</div> <div class="mw-parser-output">&nbsp;</div> <div class="mw-parser-output">&nbsp;</div> </div>

Revision as of 18:34, 26 February 2018

The CXTask class provides a mechanism for applications to request regular updates in a non-threaded manner. The application derives from CXTask and provides a CXTask::Idle() override which is called once per task update. Each CXTask must be registered with a CXTaskHost in order to receive updates.
 
Updates occur whenever the CXTaskHost::IdleTasks() function is called, which (with the exception of the main thread task host in an application) is NOT automatic.
 

Thread Task Hosts

Each thread may have a singleton CXTaskHost object. This object is created via CXTaskHost::InitCurrentThreadTaskHost(), accessed via CXTasskHost::GetCurrentThreadTaskHost(), and finally destroyed via CXTaskHost::KillCurrentThreadTaskHost(). The thread may trigger a task update by calling CXTaskHost::GetCurrentThreadTaskHost().IdleTasks().

Main Thread Task Host

The main thread task host is created automatically during cxsource initialisation, and is destroyed automatically during cxsource shutdown. In a standard event-driven application, the main thread task host is updated on a regular basis via the main event loop. In other processes, such as a command-line tool, the application must explicitly update the main thread task host on a regular basis.

Background Thread Task Hosts

Background threads do not automatically receive task hosts. If they will use task host functionality, they must explicitly create, update, and destroy the thread task host as required.

Additional Task Hosts

It is also possible to create arbitrary task hosts, and update them on a custom schedule.