Processos e Workers
Multi-tasking in 4D is the ability to have multiple operations that are executed simultaneously. Essas operações são chamadas processos. 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.
If you write thread-safe code, you can create preemptive processes that will be able to take advantage of multi-core computers in your compiled applications, for faster execution.
The 4D application creates processes for its own needs, for example the Main process to manage the display windows of the user interface, the Design process to manages the windows and editors of the Design environment (note that both are worker processes), the Web Server process, the Cache Manager process, the Indexing process, or the On Event Manager process.
Criar e limpar processos
Existem várias maneiras de criar um processo:
- Execute a method in the Design environment after checking the New Process check box in the "Execute Method" dialog box. The method chosen in the Execute Method dialog box is the process method.
- Use o comando [
New process
] (https://doc.4d.com/4dv20/help/command/en/page317.html). The method passed as a parameter to theNew process
command is the process method. - Use o comando [
Execute on server
] (https://doc.4d.com/4dv20/help/command/en/page373.html) para criar um procedimento armazenado no servidor. O método passado como parâmetro do comando é o método processo. - Use o comando [
CALL WORKER
] (https://doc.4d.com/4dv20/help/command/en/page1389.html). Se o processo worker ainda não existir, será criado.
In Desktop applications, processes can be run by choosing menu commands. In the Menu Bar editor, select the menu command and click the Start a New Process check box. O método associado ao comando do menu é o método de processo.
A process can be cleared under the following conditions (the first two conditions are automatic):
- Quando o método processo termina de ser executado
- Quando o usuário sai da aplicação
- If you stop the process procedurally or use the Abort button in the Debugger or in the Runtime Explorer
- If you call the
KILL WORKER
command (to delete a worker process only).
Um processo pode criar outro processo. 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.