Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
8814c0c8
Commit
8814c0c8
authored
Aug 26, 2008
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use the notify library in main_notify.c
Avoid some duplicated code in main_notify.c.
parent
4f80f53c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
10 deletions
+7
-10
main_notify.c
src/main_notify.c
+7
-10
No files found.
src/main_notify.c
View file @
8814c0c8
...
...
@@ -28,9 +28,7 @@
static
struct
ioOps
main_notify_IO
;
static
int
main_pipe
[
2
];
static
pthread_t
main_task
;
static
pthread_cond_t
main_wakeup
=
PTHREAD_COND_INITIALIZER
;
static
pthread_mutex_t
main_wakeup_mutex
=
PTHREAD_MUTEX_INITIALIZER
;
static
volatile
int
pending
;
static
Notify
main_notify
;
static
pthread_mutex_t
select_mutex
=
PTHREAD_MUTEX_INITIALIZER
;
static
int
ioops_fdset
(
fd_set
*
rfds
,
...
...
@@ -74,6 +72,7 @@ void init_main_notify(void)
main_notify_IO
.
consume
=
ioops_consume
;
registerIO
(
&
main_notify_IO
);
main_task
=
pthread_self
();
notify_init
(
&
main_notify
);
}
static
int
wakeup_via_pipe
(
void
)
...
...
@@ -95,10 +94,10 @@ void wakeup_main_task(void)
{
assert
(
!
pthread_equal
(
main_task
,
pthread_self
()));
pending
=
1
;
main_notify
.
pending
=
1
;
if
(
!
wakeup_via_pipe
())
pthread_cond_signal
(
&
main_wakeup
);
notify_signal
(
&
main_notify
);
}
void
main_notify_lock
(
void
)
...
...
@@ -117,10 +116,8 @@ void wait_main_task(void)
{
assert
(
pthread_equal
(
main_task
,
pthread_self
()));
pthread_mutex_lock
(
&
main_wakeup_mutex
);
if
(
!
pending
)
pthread_cond_wait
(
&
main_wakeup
,
&
main_wakeup_mutex
);
pending
=
0
;
pthread_mutex_unlock
(
&
main_wakeup_mutex
);
notify_enter
(
&
main_notify
);
notify_wait
(
&
main_notify
);
notify_leave
(
&
main_notify
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment