4D v16.3Processes |
||
|
4D v16.3
Processes
Processes
Multi-tasking in 4D is the ability to have distinct database operations that are executed simultaneously. These operations are called processes. Multiple processes are like multiple users on the same computer, each working on his or her own task. This essentially means that each method can be executed as a distinct database task.
Note: This section does not cover stored procedures. See the Stored Procedures section in the 4D Server Reference manual. There are several ways to create a new process:
A process can be cleared under the following conditions. The first two conditions are automatic:
A process can create another process. Processes are not organized hierarchically—all processes are equal, regardless of the process from which they have been created. Once the “parent” process creates a “child” process, the child process will continue regardless of whether or not the parent process is still executing. Each process contains specific elements. There are three types of distinctly different elements in a process:
Interface elements consist of the following:
Notes:
Data elements refer to the data used by the database. The data elements are:
Note: This description of the data elements is valid if your processes are global in scope. By default, all processes are global. See the “Global and Local Processes” section below. The language elements of a process are the elements related to programming in 4D.
User processes are processes that you create to perform certain tasks. They share processing time with the kernel processes. As an example, Web connection processes are user processes. The 4D application also creates processes for its own needs. The following processes are created and managed by 4D:
Starting with 4D v15 R5 64 bits, 4D allows you to create preemptive user processes in compiled mode. In previous versions, only cooperative user processes were available. When run in preemptive mode, a process is dedicated to a CPU. Process management is then delegated to the system, which can allocate each CPU separately on a multi-core machine. When run in cooperative mode, all processes are managed by the parent application thread and share the same CPU, even on a multi-core machine. As a result, in preemptive mode, overall performance of the application is improved, especially on multi-core machines, since multiple processes (threads) can truly run simultaneously. However, actual gains depend on the operations being executed. In return, since each thread is independent from the others in preemptive mode, and not managed directly by the application, there are specific constraints applied to methods that you want to be compliant with preemptive use. Additionally, preemptive execution is only available in certain specific contexts. Management of preemptive processes is covered in the Preemptive 4D processes section. Processes can be either global or local in scope. By default, all processes are global. Global processes can perform any operation, including accessing and manipulating data. In most cases, you will want to use global processes. Local processes should be used only for operations that do not access data. For example, you can use a local process to run an event-handling method or to control interface elements such as floating windows. You specify that a process is local in scope through its name. The name of local process must start with a dollar sign ($). Warning: If you attempt to access data from a local process, you access it though the main process, risking conflicts with operations performed within that process. 4D Server: Using local processes on the Client side for operations that do not require data access reserves more processing time for server-intensive tasks. A record is locked when another process has successfully loaded the record for modification. A locked record can be loaded by another process, but cannot be modified. The record is unlocked only in the process in which the record is being modified. A table must be in read/write mode for a record to be loaded unlocked. For more information, refer to the Record Locking section.
See also
|
PROPERTIES
Product: 4D
HISTORY
ARTICLE USAGE
4D Language Reference ( 4D v16) |