Saltar para o conteúdo principal
Versão: v19

Utilizar processos web preemptivos

The 4D Web Server allows you to take full advantage of multi-core computers by using preemptive web processes in your compiled applications. You can configure your web-related code, including 4D tags and web database methods, to run simultaneously on as many cores as possible.

For in-depth information on preemptive process in 4D, please refer to the Preemptive 4D processes section in the 4D Language Reference.

Disponibilidade do modo preemptivo para os processos web

The following table indicates whether the preemptive mode is used or is available, depending on the execution context:

4D ServerInterpreted, project (client connected locally)Interpretado, projeto (nenhum cliente ligado localmente) ou binárioCompilado
Servidor RESTcooperativopreemptivepreemptive
Servidor Webcooperativocooperativoparâmetro web
Servidor Web Servicescooperativocooperativoparâmetro web
Legado RESTcooperativoparâmetro webparâmetro web
4D remoto/usuário únicoInterpretadoCompilado
Servidor RESTcooperativopreemptive
Servidor Webcooperativoparâmetro web
Servidor Web Servicescooperativoparâmetro web
Legado RESTcooperativoparâmetro web

Escrever código servidor Web hilo seguro

All 4D code executed by the web server must be thread-safe if you want your web processes to be run in preemptive mode. When the Use preemptive processes option is checked in the Settings dialog box, the following parts of the application will be automatically evaluated by the 4D compiler:

  • Todos os métodos bases relacionados com a Web:

  • The compiler_web project method (regardless of its actual "Execution mode" property);

  • Basically any code processed by the PROCESS 4D TAGS command in the web context, for example through .shtml pages.

  • Any project method with the "Available through 4D tags and URLS (4DACTION, etc.)" attribute

  • Triggers para as tabelas com o atributo "Expor como recurso REST"

  • ORDA data model class functions called via REST

  • Métodos projeto com a propriedade "Servidor REST" marcada (chamadas REST herdadas)

For each of these methods and code parts, the compiler will check if the thread-safety rules are respected, and will return errors in case of issues. For more information about thread-safety rules, please refer to the Writing a thread-safe method paragraph in the Processes chapter of the 4D Language Reference manual.

Código web 4D hilo seguro

Most of the web-related 4D commands and functions, database methods and URLs are thread-safe and can be used in preemptive mode.

Comandos 4D e métodos base

Todos os comandos 4D relacionados à Web são thread-safe, i.e.:

  • todos os comandos do tema Servidor Web,
  • todos os comandos do tema Cliente HTTP.

The web-related database methods are thread-safe and can be used in preemptive mode (see below): On Web Authentication, On Web Connection, On REST Authentication...).

Obviamente, o código executado por esses métodos também deve ser thread-safe.

URLs do servidor Web

The following 4D Web Server URLs are thread-safe and can be used in preemptive mode:

  • 4daction/ (the called project method must also be thread-safe)
  • 4dcgi/ (the called database methods must also be thread-safe)
  • 4dwebtest/
  • 4dblank/
  • 4dstats/
  • 4dhtmlstats/
  • 4dcacheclear/
  • rest/
  • 4dimgfield/ (generated by PROCESS 4D TAGS for web request on picture fields)
  • 4dimg/ (generated by PROCESS 4D TAGS for web request on picture variables)

Ícone de processo web preemptivo

Both the Runtime Explorer and the 4D Server administration window display a specific icon for preemptive web processes:

Tipo de processoÍcone
Método web preventivo