Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-gpu
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-gpu
Commits
e2b38c96
Commit
e2b38c96
authored
May 19, 2008
by
Rémi Denis-Courmont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mprec: thread-safety
parent
f2312da8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
11 deletions
+19
-11
src/misc/mtime.c
src/misc/mtime.c
+19
-11
No files found.
src/misc/mtime.c
View file @
e2b38c96
...
...
@@ -144,6 +144,19 @@ char *secstotimestr( char *psz_buffer, int i_seconds )
return
(
psz_buffer
);
}
#if defined (HAVE_CLOCK_NANOSLEEP)
static
unsigned
prec
=
0
;
static
void
mprec_once
(
void
)
{
struct
timespec
ts
;
if
(
clock_getres
(
CLOCK_MONOTONIC
,
&
ts
))
clock_getres
(
CLOCK_REALTIME
,
&
ts
);
prec
=
ts
.
tv_nsec
/
1000
;
}
#endif
/**
* Return a value that is no bigger than the clock precision
* (possibly zero).
...
...
@@ -151,16 +164,14 @@ char *secstotimestr( char *psz_buffer, int i_seconds )
static
inline
unsigned
mprec
(
void
)
{
#if defined (HAVE_CLOCK_NANOSLEEP)
struct
timespec
ts
;
if
(
clock_getres
(
CLOCK_MONOTONIC
,
&
ts
))
clock_getres
(
CLOCK_REALTIME
,
&
ts
);
return
ts
.
tv_nsec
/
1000
;
#endif
static
pthread_once_t
once
=
PTHREAD_ONCE_INIT
;
pthread_once
(
&
once
,
mprec_once
);
return
prec
;
#else
return
0
;
#endif
}
static
unsigned
prec
=
0
;
static
volatile
mtime_t
cached_time
=
0
;
/**
...
...
@@ -315,12 +326,9 @@ mtime_t mdate( void )
*/
void
mwait
(
mtime_t
date
)
{
if
(
prec
==
0
)
prec
=
mprec
();
/* If the deadline is already elapsed, or within the clock precision,
* do not even bother the clock. */
if
(
(
date
-
cached_time
)
<
(
mtime_t
)
prec
)
// OK: mtime_t is signed
if
(
(
date
-
cached_time
)
<
(
mtime_t
)
mprec
()
)
// OK: mtime_t is signed
return
;
#if 0 && defined (HAVE_CLOCK_NANOSLEEP)
...
...
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