Skip to content

Commit aac88b7

Browse files
committed
add doxygen
1 parent a20abd4 commit aac88b7

File tree

5 files changed

+1054
-137
lines changed

5 files changed

+1054
-137
lines changed

include/vix/utils/ConsoleMutex.hpp

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
* @file ConsoleMutex.hpp
44
* @author Gaspard Kirira
55
*
6-
* Copyright 2025, Gaspard Kirira. All rights reserved.
6+
* Copyright 2025, Gaspard Kirira.
7+
* All rights reserved.
78
* https://github.com/vixcpp/vix
9+
*
810
* Use of this source code is governed by a MIT license
911
* that can be found in the License file.
1012
*
@@ -19,38 +21,79 @@
1921

2022
namespace vix::utils
2123
{
22-
24+
/**
25+
* @brief Global mutex used to serialize console output.
26+
*
27+
* This mutex can be used to ensure that log lines, banners,
28+
* or other console writes do not interleave across threads.
29+
*
30+
* @return Reference to the global console mutex.
31+
*/
2332
inline std::mutex &console_mutex()
2433
{
2534
static std::mutex m;
2635
return m;
2736
}
2837

38+
/**
39+
* @brief Mutex protecting banner-related state.
40+
*
41+
* This mutex guards access to the banner completion flag
42+
* and coordinates threads waiting for banner output.
43+
*
44+
* @return Reference to the banner mutex.
45+
*/
2946
inline std::mutex &banner_mutex()
3047
{
3148
static std::mutex m;
3249
return m;
3350
}
3451

52+
/**
53+
* @brief Condition variable used for banner synchronization.
54+
*
55+
* Threads may wait on this condition variable until the
56+
* console banner has finished rendering.
57+
*
58+
* @return Reference to the banner condition variable.
59+
*/
3560
inline std::condition_variable &console_cv()
3661
{
3762
static std::condition_variable cv;
3863
return cv;
3964
}
4065

66+
/**
67+
* @brief Flag indicating whether the console banner is done.
68+
*
69+
* When true, threads waiting for the banner may proceed.
70+
*
71+
* @return Reference to the banner completion flag.
72+
*/
4173
inline bool &console_banner_done()
4274
{
4375
static bool done = true;
4476
return done;
4577
}
4678

79+
/**
80+
* @brief Block until the console banner has completed.
81+
*
82+
* This function waits on the banner condition variable
83+
* until console_banner_done() becomes true.
84+
*/
4785
inline void console_wait_banner()
4886
{
4987
std::unique_lock<std::mutex> lk(banner_mutex());
5088
console_cv().wait(lk, []
5189
{ return console_banner_done(); });
5290
}
5391

92+
/**
93+
* @brief Mark the console banner as completed.
94+
*
95+
* Wakes all threads waiting in console_wait_banner().
96+
*/
5497
inline void console_mark_banner_done()
5598
{
5699
{
@@ -60,6 +103,13 @@ namespace vix::utils
60103
console_cv().notify_all();
61104
}
62105

106+
/**
107+
* @brief Reset the banner completion state.
108+
*
109+
* After calling this function, threads calling
110+
* console_wait_banner() will block until the banner
111+
* is marked done again.
112+
*/
63113
inline void console_reset_banner()
64114
{
65115
std::lock_guard<std::mutex> lk(banner_mutex());
@@ -68,4 +118,4 @@ namespace vix::utils
68118

69119
} // namespace vix::utils
70120

71-
#endif
121+
#endif // VIX_CONSOLE_MUTEX_HPP

0 commit comments

Comments
 (0)