Solid Fluid System Solutions  
Home Software About Hardware Firmware
Folder Icon MemMgr
 
Our ANSI style memory management module.

Document Icon VCore (Library)
Document Icon Memory Manager
Document Icon Run-time Type
Document Icon Object Creation
Document Icon Constructor / Destructor
Document Icon Error Handling
Document Icon Verification
Document Icon Serialisation
Document Icon Synchronisation
Current Document Icon Thread Completion

Thread Completion

Thread completion is an important concept that has it's root in the VObject base class.

As may be seen elsewhere, the VObject Libraries provide for a distinction of the concept of thread, the "VJob" and the "VThread". Whilst a full description is beyond the bound of this text, a VJob is a thread without a message queue. This is distinct from a "VThread" which is a thread with a message queue.

The lifespan of a VJob is usually much shorter than that of a VThread, and although these items are similar they work in quite different ways. A thread might be created and destroyed with the application object, or it might only exist for a period whilst a dialogue is on screen. Either way one would normally post a message to it in order that it begin processing. Once complete the thread might post it's results back to the originator, or it might queue them up, and wait for the originator to request them back again.

This is different from a VJob, because a VJob is unable to take further requests once it is underway. It has no message queue. It is still possible for a job to work interactively with the application, but this must be through either a functional, or pure data interface. Since these these schemes require explicit synchronisation, they can become troublesome.

VJob is intended to take instructions before it starts and post messages to a nominated VObject to indicate progress. On completion, it posts results to the nominated VObject, and exits. Typically VJob is the base class for a linear user specified procedural item that executes parallel with the calling thread. Clearly the initial instruction sent to the VJob is easy to implement, but the messaging and completion aspects are more involved.

VObject provides virtual functions OnJobMessage() and OnJobComplete() as an interface. This interface may be implemented on any VObject derived class that wishes to receive status updates and results from VJob derived objects. Not all VObjects have a message queue. As a consequence the VJob can only post messages to objects that are derived from VThread.

When one creates a VJob, not only must one specify the VObject to receive the results, but the VThread object in which the recipient resides. In normal circumstances this would be the application object VApp, which itself is derived from VThread. Nevertheless, a VThread derived object created by the VApp object is a valid job message intermediary. All VThread derived objects are capable of forwarding job status messages and results to any VObject, and by this scheme lightweight synchronisation of job results is achieved with minimal programming overhead.

Copyright © Solid Fluid 2007-2022
Last modified: SolFlu  Sat, 13 Jun 2009 02:12:57 GMT