Skip to content
Closed

test #20

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
7632696
ci: removing the trigger of 'pull_request' workflow for push events on
andrelcmoreira Nov 13, 2024
9973cab
ci: renaming the pull_request workflow
andrelcmoreira Nov 13, 2024
f0a3250
fixing CI badge on README file
andrelcmoreira Nov 14, 2024
7c3bae6
improving the README file
andrelcmoreira Nov 14, 2024
af11110
using the README.md file as main page for the auto-generated library …
andrelcmoreira Nov 20, 2024
c02946e
ci: adding the clang build on 'build' step
andrelcmoreira Nov 22, 2024
5a423ae
adding the generation of compile_commands file
andrelcmoreira Apr 5, 2025
6df4050
updating README file
andrelcmoreira Jul 11, 2025
2557d31
updating README file
andrelcmoreira Jul 11, 2025
fff51c7
ci: adding cppcheck job
andrelcmoreira Nov 16, 2025
7703357
ci: upgrading version of upload-artifact action
andrelcmoreira Nov 16, 2025
d5a79be
ci: fixing cppcheck issues
andrelcmoreira Nov 16, 2025
9d0b486
lib: adding task callbacks
andrelcmoreira Nov 22, 2025
055f14d
samples: updating C sample
andrelcmoreira Nov 22, 2025
6162129
lib: adding 'id' field to task struct
andrelcmoreira Nov 22, 2025
5f5ebe3
lib: deep copying the task parameter and adding 'param_size' paramete…
andrelcmoreira Nov 20, 2025
5f06c98
lib: fixing compiling errors
andrelcmoreira Nov 30, 2025
3754fbf
lib: checking if the provided task if bounded to the provided pool on
andrelcmoreira Nov 21, 2025
11f63f0
lib: fixing valgrind issues on unit tests
andrelcmoreira Nov 30, 2025
e1225a0
lib: removing the pool parameter on get_task_result
andrelcmoreira Nov 30, 2025
5da0002
lib: moving for_each_task and for_each_task_safe macros to queue module
andrelcmoreira Dec 6, 2025
d9ba28d
lib: preventing double free issue on task destruction
andrelcmoreira Dec 6, 2025
01c5e07
lib: fixing valgrind issues
andrelcmoreira Dec 6, 2025
ded56df
lib: fixing cppcheck issues
andrelcmoreira Dec 6, 2025
43db6fa
lib: releasing the task after its execution on async flow
andrelcmoreira Dec 8, 2025
9e2a7f6
lib: adding useful logs
andrelcmoreira Dec 8, 2025
2477e5b
lib: improving log format
andrelcmoreira Dec 8, 2025
c51d86a
lib: adding 'param' to task callbacks
andrelcmoreira Dec 15, 2025
809f468
lib: improving library API
andrelcmoreira Dec 17, 2025
8e18ce2
lib: updating doc
andrelcmoreira Dec 17, 2025
9f6693d
lib: improving task releasing on async flow
andrelcmoreira Dec 22, 2025
e464549
ci: fixing cppcheck issues
andrelcmoreira Dec 22, 2025
13e4177
lib: adding 'auto_release' parameter on create_task function to control
andrelcmoreira Dec 22, 2025
b4962ba
lib: splitting the 'create_task' function into 'create_sync_task' and
andrelcmoreira Dec 24, 2025
9eb789f
lib: fixing cppcheck and doxygen issues
andrelcmoreira Dec 24, 2025
5e94f20
lib: adding unit tests to check the 'auto release' feature
andrelcmoreira Dec 24, 2025
d8641b9
lib: refactoring thread_func function
andrelcmoreira Dec 27, 2025
a0b4200
samples: removing the C++ sample and moving the C
andrelcmoreira Dec 7, 2025
24bf43f
samples: splitting 'hello-world' sample into
andrelcmoreira Dec 7, 2025
6a34899
samples: fixing memory leak on hello-world-async sample
andrelcmoreira Dec 7, 2025
3c8f2ea
samples: adding webserver sample
andrelcmoreira Dec 7, 2025
5dff600
samples: fixing valgrind issue
andrelcmoreira Dec 12, 2025
07d7549
samples: moving the handle of GET request to handle_get_request function
andrelcmoreira Dec 12, 2025
5f8215f
samples: renaming samples
andrelcmoreira Dec 12, 2025
328e5ba
samples: fixing double free issue
andrelcmoreira Dec 12, 2025
1e168a9
lib: passing the task 'param' field to task callbacks
andrelcmoreira Dec 15, 2025
629cdbd
samples: updating the webserver sample
andrelcmoreira Dec 15, 2025
23250e0
lib: making 'param' argument constant on task callbacks
andrelcmoreira Dec 16, 2025
9787e01
samples: adding README file to the samples
andrelcmoreira Dec 16, 2025
51fdd71
samples: fixing compilation errors
andrelcmoreira Dec 18, 2025
0e249bd
lib: adding debugging logs to enqueue_task function
andrelcmoreira Dec 27, 2025
39bf4f0
samples: fixing compile errors
andrelcmoreira Dec 27, 2025
f1b83bc
lib: checking for the 'auto_release' option on get_task_result function
andrelcmoreira Dec 28, 2025
c7aaa22
lib: updating the documentation of get_task_result and wait_task_finish
andrelcmoreira Dec 28, 2025
0b3acb7
samples: updating http-server sample's README file
andrelcmoreira Jan 1, 2026
d425989
samples: improving the error handling on http-server sample
andrelcmoreira Jan 1, 2026
c40b28c
samples: improving http-server mainloop
andrelcmoreira Jan 2, 2026
5c6ec50
samples: removing memory leak on http-server sample
andrelcmoreira Jan 2, 2026
8ecac26
doc: updating e-mail
andrelcmoreira Mar 21, 2026
294ba34
samples: fixing typo on http-server sample
andrelcmoreira Mar 31, 2026
74fc6d8
samples: replacing the usage of printf by fprintf
andrelcmoreira Jan 3, 2026
0bf4fa8
samples: funcionando essa porra
andrelcmoreira Jan 3, 2026
04965bd
samples: adding the content-type verification to the http-server sample
andrelcmoreira Apr 3, 2026
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
2 changes: 2 additions & 0 deletions .clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
CompileFlags:
CompilationDatabase: "build"
28 changes: 22 additions & 6 deletions .github/workflows/pull_request.yaml → .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
name: Pull request
name: CI

on:
pull_request:
push:
branches:
- develop
push:
branches:
- main

env:
COVERAGE_REPORT_DIR: build/coverage
Expand All @@ -18,6 +15,9 @@ jobs:
build:
name: Build library
runs-on: ubuntu-latest
strategy:
matrix:
cc: [gcc, clang]
container:
image: andrelcmoreira/pool-day:v2
volumes:
Expand All @@ -29,7 +29,7 @@ jobs:
- uses: actions/checkout@v2
- name: Build library
run: |
cmake -DCMAKE_BUILD_TYPE=Debug -S . -B build
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_C_COMPILER=${{ matrix.cc }} -S . -B build
cmake --build build

build_samples:
Expand Down Expand Up @@ -71,6 +71,22 @@ jobs:
- name: Run unit tests
run: ${{ env.LD_PRELOAD }} build/test/pool-day-tests

static_analysis:
name: Run static analysis
runs-on: ubuntu-latest
container:
image: andrelcmoreira/pool-day:v2
volumes:
- ${{ github.workspace }}:/pool-day
credentials:
username: ${{ secrets.DOCKERHUB_USER }}
password: ${{ secrets.DOCKERHUB_PASS }}
steps:
- uses: actions/checkout@v2

- name: Run cppcheck
run: cppcheck --enable=all --inline-suppr -Iinclude --error-exitcode=1 --suppress=missingIncludeSystem src/*

dynamic_analysis:
name: Run dynamic analysis
runs-on: ubuntu-latest
Expand Down Expand Up @@ -139,7 +155,7 @@ jobs:

- name: Upload coverage report
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-report
path: ${{ env.COVERAGE_REPORT_DIR }}
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ option(ENABLE_LOGGING "enable library logs" OFF)
set(PROJECT_NAME "pool-day")
set(SOURCES src/task.c src/queue.c src/pool_day.c)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Werror -Wextra -Wpedantic")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS} -g3")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS} -O3 -s")
Expand Down Expand Up @@ -40,7 +41,7 @@ if(BUILD_DOCUMENTATION)
endif(BUILD_DOCUMENTATION)

if(ENABLE_LOGGING)
add_definitions(-DLIB_LOGGING)
add_definitions(-DENABLE_LOGGING)
list(APPEND SOURCES "src/logger.c")
endif(ENABLE_LOGGING)

Expand All @@ -49,5 +50,5 @@ target_link_libraries(${PROJECT_NAME} pthread)

install(TARGETS ${PROJECT_NAME} DESTINATION /usr/lib)
install(FILES include/pool_day.h DESTINATION /usr/include/pool_day)
install(FILES include/task.h DESTINATION /usr/include/pool_day)
install(FILES include/internal/errors.h DESTINATION /usr/include/pool_day/internal)
install(FILES include/internal/task.h DESTINATION /usr/include/pool_day/internal)
23 changes: 15 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
## pool-day

[![CI](https://github.com/andrelcmoreira/pool-day/actions/workflows/ci.yaml/badge.svg)](https://github.com/andrelcmoreira/pool-day/actions/workflows/ci.yaml)
[![License: LGPL v3](https://img.shields.io/badge/License-LGPL_v3-blue.svg)](https://www.gnu.org/licenses/lgpl-3.0)

#### Overview

`pool-day` is a thread pool library for C/C++ applications.
`pool-day` is a simple thread pool library for C/C++ applications built around POSIX threads.

#### Building

#### Build
The library relies on `cmake` tool to be built:

```cmake
$ cmake -S . -B build
$ cmake --build build
$ sudo cmake --install build
```

Optional build flags:
Additional flags can be supplied as parameter to cmake according to the table
below:

| Flag | Description |
|---------------------|----------------------------------------|
| BUILD_SAMPLES | Build the library samples |
| ENABLE_LOGGING | Enable library logs |
| Flag | Description |
|----------------|--------------------------------------|
| BUILD_SAMPLES | Build the library's samples |
| ENABLE_LOGGING | Enable the library's logging feature |

#### Library support
#### Support

- linux
3 changes: 2 additions & 1 deletion doc/Doxyfile.in
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@ WARN_LOGFILE =
#---------------------------------------------------------------------------
# Configuration options related to the input files
#---------------------------------------------------------------------------
INPUT = @CMAKE_CURRENT_SOURCE_DIR@/include @CMAKE_CURRENT_SOURCE_DIR@/src
INPUT = @CMAKE_CURRENT_SOURCE_DIR@/include @CMAKE_CURRENT_SOURCE_DIR@/src @CMAKE_CURRENT_SOURCE_DIR@/README.md
USE_MDFILE_AS_MAINPAGE = README.md
INPUT_ENCODING = UTF-8
INPUT_FILE_ENCODING =
FILE_PATTERNS = *.c \
Expand Down
2 changes: 1 addition & 1 deletion include/internal/errors.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @brief Contains the definition of the error codes of the library.
*
* @authors
* Copyright (C) 2023 André L. C. Moreira <andrelcmoreira@disroot.org>
* Copyright (C) 2023 André L. C. Moreira <andrelcmoreira@proton.me>
*
* @copyright
* This program is free software: you can redistribute it and/or modify
Expand Down
18 changes: 9 additions & 9 deletions include/internal/logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @brief Contains the logging functions of the library.
*
* @authors
* Copyright (C) 2023 André L. C. Moreira <andrelcmoreira@disroot.org>
* Copyright (C) 2023 André L. C. Moreira <andrelcmoreira@proton.me>
*
* @copyright
* This program is free software: you can redistribute it and/or modify
Expand All @@ -27,19 +27,19 @@
* @brief Log severity.
*/
typedef enum {
POOL_DAY_INFO_INFO,
POOL_DAY_INFO_ERROR
POOL_DAY_DEBUG_SEVERITY,
POOL_DAY_ERROR_SEVERITY
} pool_day_log_severity_t;

#ifdef LIB_LOGGING
#define POOL_DAY_INFO(...) \
__log_msg(POOL_DAY_INFO_INFO, __FILE__, __func__, __LINE__, __VA_ARGS__)
#ifdef ENABLE_LOGGING
#define POOL_DAY_DEBUG(...) \
__log_msg(POOL_DAY_DEBUG_SEVERITY, __FILE__, __func__, __LINE__, __VA_ARGS__)
#define POOL_DAY_ERROR(...) \
__log_msg(POOL_DAY_INFO_ERROR, __FILE__, __func__, __LINE__, __VA_ARGS__)
__log_msg(POOL_DAY_ERROR_SEVERITY, __FILE__, __func__, __LINE__, __VA_ARGS__)
#else
#define POOL_DAY_INFO(...)
#define POOL_DAY_DEBUG(...)
#define POOL_DAY_ERROR(...)
#endif // LIB_LOGGING
#endif // ENABLE_LOGGING

/**
* @brief Log a message to the screen.
Expand Down
12 changes: 6 additions & 6 deletions include/internal/queue.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @brief Contains the basic definitions and data structures of the task queue.
*
* @authors
* Copyright (C) 2023 André L. C. Moreira <andrelcmoreira@disroot.org>
* Copyright (C) 2023 André L. C. Moreira <andrelcmoreira@proton.me>
*
* @copyright
* This program is free software: you can redistribute it and/or modify
Expand All @@ -26,10 +26,10 @@
#include <stdbool.h>
#include <stdint.h>

typedef struct task task_t; //!< Structure representing an item on the task
// queue.
typedef struct task_queue task_queue_t; //!< Structure representing the queue
// itself.
typedef struct task *task_t; //!< Structure representing an item on the task
// queue.

/**
* @brief Get the queue size.
Expand All @@ -48,9 +48,9 @@ uint32_t queue_size(task_queue_t *queue);
* @note This function is thread-safe.
*
* @param[in,out] queue Pointer to the queue.
* @param[in] task Pointer to the task to be enqueued.
* @param[in] task Handle to the task to be enqueued.
*/
void enqueue(task_queue_t *queue, task_t *task);
void enqueue(task_queue_t *queue, task_t task);

/**
* @brief Dequeue a task from the queue.
Expand All @@ -61,7 +61,7 @@ void enqueue(task_queue_t *queue, task_t *task);
*
* @return The head task.
*/
task_t *dequeue(task_queue_t *queue);
task_t dequeue(task_queue_t *queue);

/**
* @brief Initialize the queue.
Expand Down
75 changes: 0 additions & 75 deletions include/internal/task.h

This file was deleted.

58 changes: 58 additions & 0 deletions include/internal/task_def.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* @file
*
* @brief Contains the definitions of task structure and helper methods and
* macros to handle it.
*
* @authors
* Copyright (C) 2023 André L. C. Moreira <andrelcmoreira@proton.me>
*
* @copyright
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef TASK_DEF_H_
#define TASK_DEF_H_

#include <semaphore.h>
#include <stdbool.h>
#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif // __cplusplus

/**
* @brief Pool task definition.
*/
struct task {
uint32_t id; //!< Task identifier.
bool is_orphan; //!< Flag indicating whether the task is orphaned.
bool auto_release; //!< Flag indicating whether the task must be released after its execution.
struct task *next; //!< Next element of the current instance.
struct task *prev; //!< Previous element of the current instance.
void *(*task)(void *); //!< Task callback.
void *param; //!< Parameter of the task callback.
void *ret_val; //!< Task return value.
void (*on_task_start)(uint32_t, const void *); //!< Callback executed when the task starts.
void (*on_task_end)(uint32_t, const void *, void *); //!< Callback executed when the task ends.
sem_t ready; //!< Task's semaphore.
};

typedef struct task *task_t; //!< Structure representing an item on the task queue.

#ifdef __cplusplus
}
#endif // __cplusplus

#endif // TASK_DEF_H_
2 changes: 1 addition & 1 deletion include/internal/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @brief Contains a set of utilities available for use by the library.
*
* @authors
* Copyright (C) 2023 André L. C. Moreira <andrelcmoreira@disroot.org>
* Copyright (C) 2023 André L. C. Moreira <andrelcmoreira@proton.me>
*
* @copyright
* This program is free software: you can redistribute it and/or modify
Expand Down
Loading
Loading