Preemptive processes for 4D language

Since 4D v11, the database server and SQL server both use preemptive multi-threading. Starting with 4D v13, the Web Server in Static mode also uses preemptive. Now with v15 R5, the 4D language can also be run in preemptive processes.

Your 4D compiled applications will now be able to take full advantage of multi-core computers so that their execution will be faster and they can support more connected users.

Full advantage of multi-cores

What is the difference between Cooperative and Preemptive mode?

Cooperative mode is scheduled by processes and can only use one core. Preemptive mode is scheduled by the OS and can use all available cores.

Here an example with two processes and two cores:

Cooperative vs Preemptive

How do I to execute a method in preemptive processes?

By default, 4D will execute all project methods in cooperative mode. If you want to benefit from the preemptive mode feature, the first step consists in explicitly declaring all methods that you want to be started in preemptive mode.

To do so, there is a new “Execution mode” property in the method properties. You have 3 options:

  • Can be run in preemptive mode
  • Cannot be run in preemptive mode
  • Indifferent

When you open your database with 4D v15 R5, all your methods will be set to Indifferent.

How do I to check that my code can be run in preemptive processes?

Just write your code then the compiler checks whether the method is compatible or incompatible.

To see an example, watch this video:

If you want to reproduce all the previous demonstrations yourself, we suggest that you download the following example database.

Example Database

How do I know what commands can be run in preemptive processes?

The 4D commands that can be run in preemptive processes are indicated in the documentation by a new icon. This icon is found on the top right side.

New icon in documentation

In v15 R5, a first set of commands is available. We will add more commands in following R-release.

We suggest that you download the following HDI. We have updated the “Command name” command so that you can find out whether or not the command can be run in preemptive mode.

Example Database

For more details, please take a look at the 4D v15 R5 Upgrade manual.

Vanessa Talbot
• Product Owner •Vanessa Talbot joined 4D Program team in June, 2014. As a Product Owner, she is in charge of writing the user stories then translating it to functional specifications. Her role is also to make sure that the feature implementation delivered is meeting the customer need.Since her arrival, she has worked to define key features in 4D. She has worked on most of preemptive multi-threading new features and also on a very complex subject: the new architecture for engined application. Vanessa has a degree from Telecom Saint-Etienne. She began her career at the Criminal Research Institute as a developer for the audiovisual department. She has also worked in media and medical fields as expert in technical support, production as well as documenting new features.