.. _LokAccessExecutor: ================= LokAccessExecutor ================= **Inherits:** The :ref:`LokAccessExecutor ` class separates accesses to another :ref:`Thread `. Description =========== The :ref:`LokAccessExecutor ` class is responsible for managing and separating the execution of access methods to another :ref:`Thread `, so that those operations don't block the main flow of the program. **Version**: 1.0.0 **Author**: Daniel Sousa (github.com/nadjiel _) Property Index ============== .. list-table:: :header-rows: 1 * - Type - Name - Default value * - :ref:`LokAccessStrategy ` - :ref:`access_strategy ` - ``null`` * - :ref:`Mutex ` - :ref:`_mutex ` - ``new()`` * - :ref:`Semaphore ` - :ref:`_semaphore ` - ``new()`` * - :ref:`Thread ` - :ref:`_thread ` - ``new()`` * - :ref:`bool ` - :ref:`_exit_executor ` - ``false`` * - :ref:`LokAccessOperation `[] - :ref:`_queued_operations ` - ``[]`` * - :ref:`LokAccessOperation ` - :ref:`_current_operation ` - ``null`` Method Index ============ .. list-table:: :header-rows: 1 * - Return type - Signature * - :ref:`void ` - :ref:`finish_execution `\(\)* - :ref:`bool ` - :ref:`has_queued_operations `\(\)* - :ref:`bool ` - :ref:`has_current_operation `\(\)* - :ref:`bool ` - :ref:`is_busy `\(\)* - :ref:`Dictionary ` - :ref:`request_get_file_ids `\(:ref:`String ` files_path\)* - :ref:`Dictionary ` - :ref:`request_saving `\(:ref:`String ` file_path, :ref:`String ` file_format, :ref:`Dictionary ` data, :ref:`bool ` replace = ``false``\)* - :ref:`Dictionary ` - :ref:`request_loading `\(:ref:`String ` file_path, :ref:`String ` file_format, :ref:`String `[] partition_ids = ``[]``, :ref:`String `[] accessor_ids = ``[]``, :ref:`String `[] version_numbers = ``[]``\)* - :ref:`Dictionary ` - :ref:`request_removing `\(:ref:`String ` file_path, :ref:`String ` file_format, :ref:`String `[] partition_ids = ``[]``, :ref:`String `[] accessor_ids = ``[]``, :ref:`String `[] version_numbers = ``[]``\)* - :ref:`void ` - :ref:`_start_execution `\(\)* - :ref:`void ` - :ref:`_execute `\(\)* - :ref:`void ` - :ref:`_queue_operation `\(:ref:`LokAccessOperation ` operation\)* - :ref:`LokAccessOperation ` - :ref:`_dequeue_operation `\(\)* - :ref:`LokAccessOperation ` - :ref:`_create_operation `\(:ref:`Callable ` callable\)* - :ref:`Dictionary ` - :ref:`_operate `\(:ref:`Callable ` operation_callable\)* - :ref:`Dictionary ` - :ref:`_get_saved_files_ids `\(:ref:`String ` files_path\)* - :ref:`Dictionary ` - :ref:`_save_data `\(:ref:`String ` file_path, :ref:`String ` file_format, :ref:`Dictionary ` data, :ref:`bool ` replace = ``false``\)* - :ref:`Dictionary ` - :ref:`_load_data `\(:ref:`String ` file_path, :ref:`String ` file_format, :ref:`String `[] partition_ids = ``[]``, :ref:`String `[] accessor_ids = ``[]``, :ref:`String `[] version_numbers = ``[]``\)* - :ref:`Dictionary ` - :ref:`_remove_data `\(:ref:`String ` file_path, :ref:`String ` file_format, :ref:`String `[] partition_ids = ``[]``, :ref:`String `[] accessor_ids = ``[]``, :ref:`String `[] version_numbers = ``[]``\)* - :ref:`void ` - :ref:`_push_error_no_access_strategy `\(\) Signal Descriptions =================== .. _LokAccessExecutor_operation_started: operation_started\(:ref:`StringName ` operation\) ------------------------------------------------------------- The :ref:`operation_started ` signal is emitted when an operation starts. The operation that started is passed along in the ``operation`` parameter. .. _LokAccessExecutor_operation_finished: operation_finished\(:ref:`Dictionary ` result, :ref:`StringName ` operation\) ----------------------------------------------------------------------------------------------------- The :ref:`operation_finished ` signal is emitted when an operation finishes. The result of the operation and the operation itself are passed along in the ``result`` and ``operation`` parameters. Property Descriptions ===================== .. _LokAccessExecutor_access_strategy: :ref:`LokAccessStrategy ` access_strategy = ``null`` ----------------------------------------------------------------------- The :ref:`access_strategy ` property stores the :ref:`LokAccessStrategy ` that this :ref:`LokAccessExecutor ` uses to manipulate data. .. _LokAccessExecutor__mutex: :ref:`Mutex ` _mutex = ``new()`` --------------------------------------- The :ref:`_mutex <_mutex>` property stores a :ref:`Mutex ` that helps controlling access to this :ref:`LokAccessExecutor `'s properties by multiple :ref:`Thread `s. .. _LokAccessExecutor__semaphore: :ref:`Semaphore ` _semaphore = ``new()`` --------------------------------------------------- The :ref:`_semaphore <_semaphore>` property stores a :ref:`Semaphore ` that controls the flow of the :ref:`_thread <_thread>` of this :ref:`LokAccessExecutor `. .. _LokAccessExecutor__thread: :ref:`Thread ` _thread = ``new()`` ------------------------------------------ The :ref:`_thread <_thread>` property stores a :ref:`Thread ` that executes all the heavy operation codes that this :ref:`LokAccessExecutor ` must execute. .. _LokAccessExecutor__exit_executor: :ref:`bool ` _exit_executor = ``false`` --------------------------------------------- The :ref:`_exit_executor <_exit_executor>` property stores a ``bool`` indicating if the execution of the :ref:`_thread <_thread>` should stop. .. _LokAccessExecutor__queued_operations: :ref:`LokAccessOperation `[] _queued_operations = ``[]`` ---------------------------------------------------------------------------- The :ref:`_queued_operations <_queued_operations>` property stores an :ref:`Array ` of :ref:`LokAccessOperation `s that are queued to be executed when this :ref:`LokAccessExecutor ` becomes free to execute them. .. _LokAccessExecutor__current_operation: :ref:`LokAccessOperation ` _current_operation = ``null`` ---------------------------------------------------------------------------- The :ref:`_current_operation <_current_operation>` property stores the current :ref:`LokAccessOperation ` that is being executed by this :ref:`LokAccessExecutor `. Method Descriptions =================== .. _LokAccessExecutor_finish_execution: :ref:`void ` finish_execution\(\) --------------------------------------- The :ref:`finish_execution ` method finishes the execution of this :ref:`LokAccessExecutor `'s :ref:`_thread <_thread>` by setting the :ref:`_exit_executor <_exit_executor>` property to ``false`` and awaiting the :ref:`_thread <_thread>` finish. .. _LokAccessExecutor_has_queued_operations: :ref:`bool ` has_queued_operations\(\) -------------------------------------------- The :ref:`has_queued_operations ` method returns a ``bool`` indicating if the :ref:`_queued_operations <_queued_operations>` has any operations queued. .. _LokAccessExecutor_has_current_operation: :ref:`bool ` has_current_operation\(\) -------------------------------------------- The :ref:`has_current_operation ` method returns a ``bool`` indicating if the :ref:`_current_operation <_current_operation>` has an operation. .. _LokAccessExecutor_is_busy: :ref:`bool ` is_busy\(\) ------------------------------ The :ref:`has_current_operation ` method returns a ``bool`` indicating if this :ref:`LokAccessExecutor ` is currently busy with a :ref:`_current_operation <_current_operation>` or will be busy with one of the :ref:`_queued_operations <_queued_operations>`. .. _LokAccessExecutor_request_get_file_ids: :ref:`Dictionary ` request_get_file_ids\(:ref:`String ` files_path\) ---------------------------------------------------------------------------------------- The :ref:`request_get_file_ids ` method queues an operation of getting the saved files' ids to be executed by this :ref:`LokAccessExecutor ` the sooner the possible. The parameters of this method and its return are the same of the :ref:`LokAccessStrategy.get_saved_files_ids `, with the exception that this method is asynchronous. .. _LokAccessExecutor_request_saving: :ref:`Dictionary ` request_saving\(:ref:`String ` file_path, :ref:`String ` file_format, :ref:`Dictionary ` data, :ref:`bool ` replace = ``false``\) -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- The :ref:`request_saving ` method queues a saving operation to be executed by this :ref:`LokAccessExecutor ` the sooner the possible. The parameters of this method and its return are the same of the :ref:`LokAccessStrategy.save_data `, with the exception that this method is asynchronous. .. _LokAccessExecutor_request_loading: :ref:`Dictionary ` request_loading\(:ref:`String ` file_path, :ref:`String ` file_format, :ref:`String `[] partition_ids = ``[]``, :ref:`String `[] accessor_ids = ``[]``, :ref:`String `[] version_numbers = ``[]``\) -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- The :ref:`request_loading ` method queues a loading operation to be executed by this :ref:`LokAccessExecutor ` the sooner the possible. The parameters of this method and its return are the same of the :ref:`LokAccessStrategy.load_data `, with the exception that this method is asynchronous. .. _LokAccessExecutor_request_removing: :ref:`Dictionary ` request_removing\(:ref:`String ` file_path, :ref:`String ` file_format, :ref:`String `[] partition_ids = ``[]``, :ref:`String `[] accessor_ids = ``[]``, :ref:`String `[] version_numbers = ``[]``\) --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- The :ref:`request_removing ` method queues a reading operation to be executed by this :ref:`LokAccessExecutor ` the sooner the possible. The parameters of this method and its return are the same of the :ref:`LokAccessStrategy.remove_data `, with the exception that this method is asynchronous. .. _LokAccessExecutor__start_execution: :ref:`void ` _start_execution\(\) --------------------------------------- The :ref:`_start_execution <_start_execution>` method starts the execution of this :ref:`LokAccessExecutor `'s :ref:`_thread <_thread>` with the :ref:`_execute <_execute>` method. .. _LokAccessExecutor__execute: :ref:`void ` _execute\(\) ------------------------------- The :ref:`_execute <_execute>` method is responsible for executing the :ref:`LokAccessOperation `s ordered to this :ref:`LokAccessExecutor ` and always keep waiting for more, unless the :ref:`_exit_executor <_exit_executor>` is set to ``false``. .. _LokAccessExecutor__queue_operation: :ref:`void ` _queue_operation\(:ref:`LokAccessOperation ` operation\) ----------------------------------------------------------------------------------------------- The :ref:`_queue_operation <_queue_operation>` method takes a new :ref:`LokAccessOperation ` and appends it to the :ref:`_queued_operations <_queued_operations>` property, so that this ``operation`` can be executed the sooner possible. .. _LokAccessExecutor__dequeue_operation: :ref:`LokAccessOperation ` _dequeue_operation\(\) --------------------------------------------------------------------- The :ref:`_dequeue_operation <_dequeue_operation>` method removes a :ref:`LokAccessOperation ` from the :ref:`_queued_operations <_queued_operations>` property and returns it, so that it can be used for execution. .. _LokAccessExecutor__create_operation: :ref:`LokAccessOperation ` _create_operation\(:ref:`Callable ` callable\) ------------------------------------------------------------------------------------------------------- The :ref:`_create_operation <_create_operation>` method creates a new :ref:`LokAccessOperation ` and returns it, making sure to connect its signals to the :ref:`operation_started ` and :ref:`operation_finished ` signals. .. _LokAccessExecutor__operate: :ref:`Dictionary ` _operate\(:ref:`Callable ` operation_callable\) ---------------------------------------------------------------------------------------- The :ref:`_operate <_operate>` method receives an ``operation_callable`` and creates a new :ref:`LokAccessOperation `, which is appended to the :ref:`_queued_operations <_queued_operations>`, so that the :ref:`_thread <_thread>` can execute it in the :ref:`_execute <_execute>` method. This method then, returns the result of the operation when it is ready by awaiting the :ref:`LokAccessOperation.finished ` signal. .. _LokAccessExecutor__get_saved_files_ids: :ref:`Dictionary ` _get_saved_files_ids\(:ref:`String ` files_path\) ---------------------------------------------------------------------------------------- The :ref:`_get_saved_files_ids <_get_saved_files_ids>` method is responsible for using the :ref:`access_strategy ` to get the file ids of the saved files. This method is wrapped by the :ref:`request_get_file_ids ` method, so that it can be executed asynchronously. If you want more information about its parameters and return, see the :ref:`LokAccessStrategy.get_saved_files_ids ` method, which has the same signature. .. _LokAccessExecutor__save_data: :ref:`Dictionary ` _save_data\(:ref:`String ` file_path, :ref:`String ` file_format, :ref:`Dictionary ` data, :ref:`bool ` replace = ``false``\) ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- The :ref:`_save_data <_save_data>` method is responsible for using the :ref:`access_strategy ` to save data. This method is wrapped by the :ref:`request_saving ` method, so that it can be executed asynchronously. If you want more information about its parameters and return, see the :ref:`LokAccessStrategy.save_data ` method, which has the same signature. .. _LokAccessExecutor__load_data: :ref:`Dictionary ` _load_data\(:ref:`String ` file_path, :ref:`String ` file_format, :ref:`String `[] partition_ids = ``[]``, :ref:`String `[] accessor_ids = ``[]``, :ref:`String `[] version_numbers = ``[]``\) --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- The :ref:`_load_data <_load_data>` method is responsible for using the :ref:`access_strategy ` to load data. This method is wrapped by the :ref:`request_loading ` method, so that it can be executed asynchronously. If you want more information about its parameters and return, see the :ref:`LokAccessStrategy.load_data ` method, which has the same signature. .. _LokAccessExecutor__remove_data: :ref:`Dictionary ` _remove_data\(:ref:`String ` file_path, :ref:`String ` file_format, :ref:`String `[] partition_ids = ``[]``, :ref:`String `[] accessor_ids = ``[]``, :ref:`String `[] version_numbers = ``[]``\) ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- The :ref:`_remove_data <_remove_data>` method is responsible for using the :ref:`access_strategy ` to remove data. This method is wrapped by the :ref:`request_removing ` method, so that it can be executed asynchronously. If you want more information about its parameters and return, see the :ref:`LokAccessStrategy.remove_data ` method, which has the same signature. .. _LokAccessExecutor__push_error_no_access_strategy: :ref:`void ` _push_error_no_access_strategy\(\) ----------------------------------------------------- The :ref:`_push_error_no_access_strategy <_push_error_no_access_strategy>` method pushes an error warning that no :ref:`LokAccessStrategy `s are set in this :ref:`LokAccessExecutor `.