Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Private folder doc #390

Merged
merged 5 commits into from
Nov 11, 2023
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 113 additions & 0 deletions include/private/entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,137 @@
# include <stumpless/severity.h>
# include "private/strbuilder.h"

/**
* Frees entry cache
*
* **Thread Safety: MT-Unsafe**
* This function is not thread safe as it destroys resources(entry cache)
* that other threads can use.
*
* **Async Signal Safety: AS-Unsafe**
* This function is not safe to call from signal handlers due to destroying
* resources(entry cache) that might be used within a function.
*
* **Async Cancel Safety: AC-Unsafe**
* This function is not safe to call from threads that may be asynchronously
* cancelled, due to leaving memory in an undefined state.
*
* @since release v1.6.0
goatshriek marked this conversation as resolved.
Show resolved Hide resolved
*
*/
void
entry_free_all( void );

/**
* Gets the priority value from facility and severity parameters.
*
* Priority value is calculated by left shifting the facility value by 3
* and adding it to the severity value which is according to the
* RFC 5424 Section 6.2.1. The shift operation is done prior to get_prival()
* function with macros in "facility.h"
goatshriek marked this conversation as resolved.
Show resolved Hide resolved
*
* **Thread Safety: MT-Safe**
* This function is thread safe.
*
* **Async Signal Safety: AS-Safe **
* This function must be safe to call from signal handlers
*
* **Async Cancel Safety: AC-Safe**
* This function must be safe to call from threads that may be asynchronously
* cancelled.
*
* @since release v2.0.0
*
* @param facility Facility value. This should be a \c STUMPLESS_FACILITY value.
*
* @param severity Severity value. This should be a \c STUMPLESS_SEVERITY value
*
* @return Priority value
*/
int
get_prival( enum stumpless_facility facility,
enum stumpless_severity severity );

/**
* Locks the mutex within the entry.
*
* **Thread Safety: MT-Safe**
* This function is thread safe.
*
* **Async Signal Safety: AS-Unsafe **
* This function is not safe to call from signal handlers due to the use of
* function 'pthread_mutex_lock()' from <pthread.h> that is not guarenteed to
goatshriek marked this conversation as resolved.
Show resolved Hide resolved
* be async signal safe.
*
* **Async Cancel Safety: AC-Unsafe**
* This function is not safe to call from threads that may be asynchronously
* cancelled, due to the use of lock that could be left in undefined state.
*
* @since release v2.0.0
*
* @param entry The entry to be locked.
*
*/
void
lock_entry( const struct stumpless_entry *entry );

/**
* Adds the element to the entry.
*
* **Thread Safety: MT-Unsafe**
* This function is not thread safe as it doesn't use any synchronization
* or locking mechanisms while accessing shared resources.
*
* **Async Signal Safety: AS-Unsafe**
* This function is not safe to call from signal handlers due to the use of
* memory functions.
*
* **Async Cancel Safety: AC-Unsafe**
* This function is not safe to call from threads that may be asynchronously
* cancelled, due to the use of memory functions that could leave the
* memory in undefined state.
*
* @since release v2.6.0
*
* @param entry The entry to add the new element.
*
* @param element The new element to add to entry.
*
* @return The modified entry if no error is encountered. If an error is
* encountered NULL is returned.
*/
struct stumpless_entry *
locked_add_element( struct stumpless_entry *entry,
struct stumpless_element *element );

/**
* Returns the element located at index within the entry.
*
* **Thread Safety: MT-Unsafe**
* This function is not thread safe as it doesn't use any synchronization
* or locking mechanisms while accessing shared resources.
*
* **Async Signal Safety: AS-Safe**
* This function is safe to call from signal handlers.
*
* **Async Cancel Safety: AC-Safe**
* This function is safe to call from threads that may be asynchronously
* canceled.
goatshriek marked this conversation as resolved.
Show resolved Hide resolved
*
* @since release v2.0.0
*
* @param entry The entry to get the element from.
*
* @param index The index of element within the entry.
*
* @return The element if no error is encountered. If an error is
* encountered, then NULL is returned and an error code is set appropriately.
*/
struct stumpless_element *
locked_get_element_by_index( const struct stumpless_entry *entry,
size_t index );


goatshriek marked this conversation as resolved.
Show resolved Hide resolved
struct stumpless_element *
locked_get_element_by_name( const struct stumpless_entry *entry,
const char *name );
Expand Down