QSC Post Quantum Cryptographic Library 1.0.0.6c (A6)
A post quantum secure library written in Ansi C
 
Loading...
Searching...
No Matches
threadpool.h
Go to the documentation of this file.
1/* 2025 Quantum Resistant Cryptographic Solutions Corporation
2 * All Rights Reserved.
3 *
4 * NOTICE: This software and all accompanying materials are the exclusive
5 * property of Quantum Resistant Cryptographic Solutions Corporation (QRCS).
6 * The intellectual and technical concepts contained within this implementation
7 * are proprietary to QRCS and its authorized licensors and are protected under
8 * applicable U.S. and international copyright, patent, and trade secret laws.
9 *
10 * CRYPTOGRAPHIC STANDARDS:
11 * - This software includes implementations of cryptographic algorithms such as
12 * SHA3, AES, and others. These algorithms are public domain or standardized
13 * by organizations such as NIST and are NOT the property of QRCS.
14 * - However, all source code, optimizations, and implementations in this library
15 * are original works of QRCS and are protected under this license.
16 *
17 * RESTRICTIONS:
18 * - Redistribution, modification, or unauthorized distribution of this software,
19 * in whole or in part, is strictly prohibited.
20 * - This software is provided for non-commercial, educational, and research
21 * purposes only. Commercial use in any form is expressly forbidden.
22 * - Licensing and authorized distribution are solely at the discretion of QRCS.
23 * - Any use of this software implies acceptance of these restrictions.
24 *
25 * DISCLAIMER:
26 * This software is provided "as is," without warranty of any kind, express or
27 * implied, including but not limited to warranties of merchantability or fitness
28 * for a particular purpose. QRCS disclaims all liability for any direct, indirect,
29 * incidental, or consequential damages resulting from the use or misuse of this software.
30 *
31 * FULL LICENSE:
32 * This software is subject to the **Quantum Resistant Cryptographic Solutions
33 * Proprietary License (QRCS-PL)**. The complete license terms are included
34 * in the LICENSE.txt file distributed with this software.
35 *
36 * Written by: John G. Underhill
37 * Contact: john.underhill@protonmail.com
38 */
39
40#ifndef QSC_THREADPOOL_H
41#define QSC_THREADPOOL_H
42
43#include "common.h"
44#include "async.h"
45
46QSC_CPLUSPLUS_ENABLED_START
47
87
88/* bogus winbase.h error */
90
91
95#define QSC_THREADPOOL_THREADS_MAX 1024ULL
96
101typedef struct
102{
104 size_t tcount;
106
114QSC_EXPORT_API bool qsc_threadpool_add_task(qsc_threadpool_state* ctx, void (*func)(void*), void* state);
115
122
129
136
146
154
155QSC_CPLUSPLUS_ENABLED_END
156
157#endif
Asynchronous Thread and Mutex Management Functions.
Contains common definitions for the Quantum Secure Cryptographic (QSC) library.
#define QSC_EXPORT_API
API export macro for Microsoft compilers when importing from a DLL.
Definition common.h:520
#define QSC_SYSTEM_CONDITION_IGNORE(x)
MSVC-specific macro to disable a specific warning condition.
Definition common.h:784
The thread pool state.
Definition threadpool.h:102
qsc_thread tpool[QSC_THREADPOOL_THREADS_MAX]
Definition threadpool.h:103
size_t tcount
Definition threadpool.h:104
QSC_EXPORT_API void qsc_threadpool_initialize(qsc_threadpool_state *ctx)
Initialize the thread-pool.
QSC_EXPORT_API void qsc_threadpool_sort(qsc_threadpool_state *ctx)
Sort the threads in the pool, placing active threads at the start of the array.
QSC_EXPORT_API bool qsc_threadpool_thread_active(const qsc_threadpool_state *ctx, size_t index)
Check if a thread is active.
QSC_EXPORT_API void qsc_threadpool_clear(qsc_threadpool_state *ctx)
Clear all tasks from the thread-pool.
#define QSC_THREADPOOL_THREADS_MAX
The thread pool maximum threads.
Definition threadpool.h:95
QSC_EXPORT_API bool qsc_threadpool_add_task(qsc_threadpool_state *ctx, void(*func)(void *), void *state)
Add a task to the thread-pool.
QSC_EXPORT_API void qsc_threadpool_remove_task(qsc_threadpool_state *ctx, size_t index)
Remove a task from the thread-pool.