CBFS Connect 2020 Delphi Edition

Questions / Feedback?

Threading and Concurrency

Through the use of multithreading, the CBFS component provides powerful concurrency features to help applications maximize their performance. For data integrity purposes, the component also strictly enforces the order in which events fire in certain situations, and allows applications to specify the extent to which events should be fired concurrently.

Please note that, even when configured for minimal concurrency, the component always fires events in the context of some worker thread, not in the thread the component was originally created on. Therefore, applications must be sure to synchronize operations between event handlers and other threads as necessary (including, but not limited to, calls to the component instance, unless a method is explicitly documented as callable within events).

Configuring Event Concurrency

Generally speaking, the CBFS component will always enforce per-file event serialization; that is, it always fires events relating to the same file in sequence (though technically-speaking, there is one optional exception to this behavior, discussed at the end of this section). For example, if there are multiple read or write operations pending against a given file, then an event will be fired for the first operation, and after its event handler has returned, another event will be fired for the second operation; and so on.

With per-file event serialization already assured, the most important concurrency-related consideration for CBFS-based applications is whether to enforce multi-file event serialization as well. The component's SerializeEvents property controls whether events relating to different files should be serialized on a single worker thread, or fired in parallel on several; by default, this property is disabled, and events for different files are allowed to fire in parallel.

When the SerializeEvents property is disabled, the MinWorkerThreadCount and MaxWorkerThreadCount configuration settings control the minimum and maximum number of worker threads the component can use for firing events. By default, both are set to 0, which indicates that the CBFS system driver should automatically choose appropriate values based on how many CPU cores the system has. These settings are both ignored if SerializeEvents is enabled.

As mentioned previously, the CBFS component offers one feature that alters its otherwise strictly-enforced per-file event serialization model: the ability to handle non-overlapping read operations on a single file in parallel. This functionality is controlled by the SerializeAccess property, which is enabled by default. This property is ignored if SerializeEvents is enabled.

Copyright (c) 2022 Callback Technologies, Inc. - All rights reserved.
CBFS Connect 2020 Delphi Edition - Version 20.0 [Build 8348]