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
ad430c66
Commit
ad430c66
authored
Nov 05, 2010
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
timer: add function timer_delay()
parent
ec48b5ea
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
0 deletions
+19
-0
timer.c
src/timer.c
+13
-0
timer.h
src/timer.h
+6
-0
No files found.
src/timer.c
View file @
ad430c66
...
@@ -71,6 +71,19 @@ void timer_add(Timer *timer, int size)
...
@@ -71,6 +71,19 @@ void timer_add(Timer *timer, int size)
timer
->
time
+=
((
uint64_t
)
size
*
1000000
)
/
timer
->
rate
;
timer
->
time
+=
((
uint64_t
)
size
*
1000000
)
/
timer
->
rate
;
}
}
unsigned
timer_delay
(
const
Timer
*
timer
)
{
int64_t
delay
=
timer
->
time
-
now
();
if
(
delay
<
0
)
return
0
;
if
(
delay
>
1000
*
1000
*
1000
)
return
1000
*
1000
;
return
delay
/
1000
;
}
void
timer_sync
(
Timer
*
timer
)
void
timer_sync
(
Timer
*
timer
)
{
{
int64_t
sleep_duration
;
int64_t
sleep_duration
;
...
...
src/timer.h
View file @
ad430c66
...
@@ -40,6 +40,12 @@ void timer_reset(Timer *timer);
...
@@ -40,6 +40,12 @@ void timer_reset(Timer *timer);
void
timer_add
(
Timer
*
timer
,
int
size
);
void
timer_add
(
Timer
*
timer
,
int
size
);
/**
* Returns the number of milliseconds to sleep to get back to sync.
*/
unsigned
timer_delay
(
const
Timer
*
timer
);
void
timer_sync
(
Timer
*
timer
);
void
timer_sync
(
Timer
*
timer
);
#endif
#endif
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