FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
UserSpaceThread/notification_queue.cpp at main · ddeka0/UserSpaceThread · GitHub
ddeka0
/
UserSpaceThread
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Issues
0
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
UserSpaceThread
/
notification_queue.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
53 lines (50 loc) · 954 Bytes
Breadcrumbs
UserSpaceThread
/
notification_queue.cpp
Copy path
File metadata and controls
53 lines (50 loc) · 954 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
*
* @file notification_queue.cpp
* @author d.deka (https://ddeka0.github.io/)
* @brief
* @version 0.1
* @date 2021-02-14
*
*/
#
include
"
notification_queue.hpp
"
#
include
"
logger.hpp
"
/*
* done()
* @brief
* Thread safe queue, where user threads are kept
*/
void
notification_queue::done
() {
{
lock_t
lock{_mutex};
_done =
true
;
}
_ready.
notify_all
();
}
/*
*
* @brief pop(ThreadCtx** x)
*
* @param x
* @return true
* @return false
*/
bool
notification_queue::pop
(ThreadCtx** x) {
lock_t
lock{_mutex};
_ready.
wait
(lock,[
this
]() {
Log
(
"
Sleeping ....TID =
"
,
THIS_THREAD_ID
);
return
!_q.
empty
() || _done;
});
if
(_q.
empty
() || _done) {
return
false
;
}
*x =
std::move
(_q.
front
());
_q.
pop_front
();
return
true
;
}
/*
*
* @brief
*
* @return std::size_t
*/
std::
size_t
notification_queue::get_size
() {
lock_t
lock{_mutex};
return
_q.
size
();
}
Back
|
FazBrowse Home
|
New Git URL