From e1b3170ba2540d19d499dc6ab010588d8f17fc6d Mon Sep 17 00:00:00 2001 From: m1maker Date: Sat, 7 Dec 2024 14:24:28 +0300 Subject: [PATCH] Document a new/recoded stuff. --- .../Namespaces/Global/Classes/fast_mutex.md | 25 +++++++++ .../Namespaces/Global/Classes/mutex.md | 25 +++++++++ .../Namespaces/Global/Classes/named_mutex.md | 17 ++++++ .../Namespaces/Global/Classes/thread.md | 3 +- docs/Foundation/Namespaces/Global/Funcdefs.md | 2 +- .../Namespaces/filesystem/Functions.md | 53 +++++++++++++++++++ .../Namespaces/this_thread/Functions.md | 9 ++++ docs/Helper/instance.md | 16 ++++++ 8 files changed, 148 insertions(+), 2 deletions(-) create mode 100644 docs/Foundation/Namespaces/Global/Classes/fast_mutex.md create mode 100644 docs/Foundation/Namespaces/Global/Classes/mutex.md create mode 100644 docs/Foundation/Namespaces/Global/Classes/named_mutex.md create mode 100644 docs/Foundation/Namespaces/filesystem/Functions.md create mode 100644 docs/Foundation/Namespaces/this_thread/Functions.md create mode 100644 docs/Helper/instance.md diff --git a/docs/Foundation/Namespaces/Global/Classes/fast_mutex.md b/docs/Foundation/Namespaces/Global/Classes/fast_mutex.md new file mode 100644 index 0000000..f095a02 --- /dev/null +++ b/docs/Foundation/Namespaces/Global/Classes/fast_mutex.md @@ -0,0 +1,25 @@ +## Fast Mutex Operations + +### `fast_mutex()` +- **Return Type**: fast_mutex@ +- **Description**: Constructs a new fast mutex object. This type of mutex is designed for higher performance than regular mutexes, particularly in scenarios with frequent lock contention. + +### `void lock(int milliseconds)` +- **Return Type**: void +- **Description**: Acquires the fast mutex. If the mutex is already locked by another thread, this will block for up to `milliseconds` before timing out and returning. + +### `bool try_lock(int milliseconds)` +- **Return Type**: bool +- **Description**: Attempts to acquire the fast mutex without blocking. Returns true if the mutex was successfully acquired within `milliseconds`; otherwise, returns false immediately. + +### `void lock()` +- **Return Type**: void +- **Description**: Acquires the fast mutex, similar to the overload with an integer parameter. If the mutex is already locked by another thread, this will block indefinitely until the lock becomes available. + +### `bool try_lock()` +- **Return Type**: bool +- **Description**: Attempts to acquire the fast mutex without blocking, as per the integer-parameter version. Returns true if the mutex was successfully acquired within an unspecified amount of time; otherwise, returns false immediately. + +### `void unlock()` +- **Return Type**: void +- **Description**: Releases the lock on the fast mutex that is currently held by the calling thread, allowing other threads waiting to acquire it to proceed. diff --git a/docs/Foundation/Namespaces/Global/Classes/mutex.md b/docs/Foundation/Namespaces/Global/Classes/mutex.md new file mode 100644 index 0000000..fc9877c --- /dev/null +++ b/docs/Foundation/Namespaces/Global/Classes/mutex.md @@ -0,0 +1,25 @@ +## Mutex Operations + +### `mutex()` +- **Return Type**: mutex@ +- **Description**: Constructs a new mutex object. + +### `void lock(int milliseconds)` +- **Return Type**: void +- **Description**: Acquires the mutex. If the mutex is already locked by another thread, this will block for up to `milliseconds` before timing out and returning. + +### `bool try_lock(int milliseconds)` +- **Return Type**: bool +- **Description**: Attempts to acquire the mutex without blocking. Returns true if the mutex was successfully acquired within `milliseconds`; otherwise, returns false immediately. + +### `void lock()` +- **Return Type**: void +- **Description**: Acquires the mutex, similar to the overload with an integer parameter. If the mutex is already locked by another thread, this will block indefinitely until the lock becomes available. + +### `bool try_lock()` +- **Return Type**: bool +- **Description**: Attempts to acquire the mutex without blocking, as per the integer-parameter version. Returns true if the mutex was successfully acquired within an unspecified amount of time; otherwise, returns false immediately. + +### `void unlock()` +- **Return Type**: void +- **Description**: Releases the lock on the mutex that is currently held by the calling thread, allowing other threads waiting to acquire it to proceed. diff --git a/docs/Foundation/Namespaces/Global/Classes/named_mutex.md b/docs/Foundation/Namespaces/Global/Classes/named_mutex.md new file mode 100644 index 0000000..e562425 --- /dev/null +++ b/docs/Foundation/Namespaces/Global/Classes/named_mutex.md @@ -0,0 +1,17 @@ +## Named Mutex Operations + +### `named_mutex(const string&in name)` +- **Return Type**: named_mutex@ +- **Description**: Constructs a new named mutex object with the specified name. Named mutexes allow multiple threads or processes to synchronize access by referring to the same unique name. + +### `void lock()` +- **Return Type**: void +- **Description**: Acquires the named mutex. If the mutex is already locked by another thread or process, this will block until the lock becomes available. + +### `bool try_lock()` +- **Return Type**: bool +- **Description**: Attempts to acquire the named mutex without blocking. Returns true if the mutex was successfully acquired; otherwise, returns false immediately. + +### `void unlock()` +- **Return Type**: void +- **Description**: Releases the lock on the named mutex that is currently held by the calling thread or process, allowing other threads or processes waiting to acquire it to proceed. diff --git a/docs/Foundation/Namespaces/Global/Classes/thread.md b/docs/Foundation/Namespaces/Global/Classes/thread.md index fe871aa..8fba99b 100644 --- a/docs/Foundation/Namespaces/Global/Classes/thread.md +++ b/docs/Foundation/Namespaces/Global/Classes/thread.md @@ -4,9 +4,10 @@ The `thread` class provides a data structure for managing and controlling thread ## Constructors -### `thread(thread_func@ func)` +### `thread(thread_func@ func, dictionary@ args = null)` - **Parameters**: - `func` (thread_func@): A function to be executed by the new thread. + - `args` (dictionary@): A dictionary with arguments handled by thread_func. - **Description**: Constructs a new `thread` object and starts executing the specified function in a separate thread. ## Methods diff --git a/docs/Foundation/Namespaces/Global/Funcdefs.md b/docs/Foundation/Namespaces/Global/Funcdefs.md index 4b61042..74b2418 100644 --- a/docs/Foundation/Namespaces/Global/Funcdefs.md +++ b/docs/Foundation/Namespaces/Global/Funcdefs.md @@ -12,5 +12,5 @@ ### thread_func - **Return Type**: `void` -- **Parameters**: None +- **Parameters**: dictionary@ args - **Description**: This function defines the entry point for a new thread. It is responsible for the execution of tasks within that thread. diff --git a/docs/Foundation/Namespaces/filesystem/Functions.md b/docs/Foundation/Namespaces/filesystem/Functions.md new file mode 100644 index 0000000..bacca00 --- /dev/null +++ b/docs/Foundation/Namespaces/filesystem/Functions.md @@ -0,0 +1,53 @@ +## Filesystem Information + +### `bool exists(const string&in path)` +- **Return Type**: bool +- **Description**: Checks if the specified file or directory exists at the given path. Returns true if it exists; otherwise, returns false. + +### `bool is_directory(const string&in path)` +- **Return Type**: bool +- **Description**: Determines if the specified path refers to a directory. Returns true if it does; otherwise, returns false. + +### `string get_current_path() property` +- **Return Type**: string +- **Description**: Retrieves the current working directory of the application as a property. + +### `void set_current_path(const string&in path) property` +- **Return Type**: void +- **Description**: Changes the current working directory to the specified new path. The method does not return any value. + +### `void list_directory(const string&in path = current_path, array@ files = null, array@ folders = null, const string&in pattern = '*')` +- **Return Type**: void +- **Description**: Lists all files and directories in the specified path that match the given pattern. If no arrays are provided for storing results, the method will not store them. + +### `bool create_directory(const string&in path)` +- **Return Type**: bool +- **Description**: Creates a new directory at the specified path. Returns true if the directory is successfully created; otherwise, returns false. + +### `bool remove(const string&in path)` +- **Return Type**: bool +- **Description**: Deletes the file or directory at the specified path. If a directory is deleted and it contains files, those files will also be removed. Returns true if the operation is successful; otherwise, returns false. + +### `bool rename(const string&in old, const string&in new)` +- **Return Type**: bool +- **Description**: Renames a file or directory from its current name to a new one. Returns true if the operation is successful; otherwise, returns false. + +### `string get_file_extension(const string&in path)` +- **Return Type**: string +- **Description**: Extracts and returns the extension (including the dot) of the specified file path. + +### `bool copy(const string&in source, const string&in des)` +- **Return Type**: bool +- **Description**: Copies a file from the source to the destination. Returns true if the operation is successful; otherwise, returns false. + +### `bool move(const string&in source, const string&in des)` +- **Return Type**: bool +- **Description**: Moves a file or directory from the source path to the destination path. Similar to renaming but can also be used for moving directories across drives. Returns true if the operation is successful; otherwise, returns false. + +### `uint64 get_file_size(const string&in path)` +- **Return Type**: uint64 +- **Description**: Retrieves and returns the size of the specified file in bytes. + +### `datetime get_last_modified_time(const string&in path)` +- **Return Type**: datetime +- **Description**: Returns the last modified time for the specified file or directory. diff --git a/docs/Foundation/Namespaces/this_thread/Functions.md b/docs/Foundation/Namespaces/this_thread/Functions.md new file mode 100644 index 0000000..8fe3ed3 --- /dev/null +++ b/docs/Foundation/Namespaces/this_thread/Functions.md @@ -0,0 +1,9 @@ +## Current thread Information + +### `void yield()` +- **Return Type**: void +- **Description**: Yields control to another thread by placing the current thread at the end of the queue for threads ready to run, allowing other threads to run. + +### `int get_id() property` +- **Return Type**: int +- **Description**: Retrieves the unique identifier of the currently executing thread as a property. diff --git a/docs/Helper/instance.md b/docs/Helper/instance.md new file mode 100644 index 0000000..d29e70e --- /dev/null +++ b/docs/Helper/instance.md @@ -0,0 +1,16 @@ +# Class: instance + +The `instance` class provides a data structure for managing an application instance. It allows you to check if the instance is currently running. + +## Constructors + +### `instance(const string&in application_name)` +- **Parameters**: + - `application_name` (const string&): The name of the application. +- **Description**: Constructs a new `instance` object and attempts to manage the specified application instance. + +## Methods + +### `bool is_running()` +- **Return Type**: bool +- **Description**: Returns whether the managed application instance is currently running.