Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
timeout.c
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
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
Kirill Smelkov
timeout.c
Commits
d453fc96
Commit
d453fc96
authored
Jan 03, 2014
by
william
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
forgot to define timeouts_open() and timeouts_close(); add timeouts_hz()
parent
13c02447
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
1 deletion
+56
-1
timeout.c
timeout.c
+52
-0
timeout.h
timeout.h
+4
-1
No files found.
timeout.c
View file @
d453fc96
...
...
@@ -26,6 +26,7 @@
#include <limits.h>
/* CHAR_BIT */
#include <stddef.h>
/* NULL */
#include <stdlib.h>
/* malloc(3) free(3) */
#include <stdio.h>
/* FILE fprintf(3) */
#include <inttypes.h>
/* UINT64_C uint64_t */
...
...
@@ -34,6 +35,8 @@
#include <string.h>
/* memset(3) */
#include <errno.h>
/* errno */
#include <sys/queue.h>
/* TAILQ(3) */
#include "timeout.h"
...
...
@@ -225,6 +228,55 @@ static struct timeouts *timeouts_init(struct timeouts *T, timeout_t hz) {
}
/* timeouts_init() */
TIMEOUT_PUBLIC
struct
timeouts
*
timeouts_open
(
timeout_t
hz
,
int
*
error
)
{
struct
timeouts
*
T
;
if
((
T
=
malloc
(
sizeof
*
T
)))
return
timeouts_init
(
T
,
hz
);
*
error
=
errno
;
return
NULL
;
}
/* timeouts_open() */
static
void
timeouts_reset
(
struct
timeouts
*
T
)
{
struct
timeouts_list
reset
;
struct
timeout
*
to
;
TAILQ_INIT
(
&
reset
);
for
(
unsigned
i
=
0
;
i
<
countof
(
T
->
wheel
);
i
++
)
{
for
(
unsigned
j
=
0
;
j
<
countof
(
T
->
wheel
[
i
]);
j
++
)
{
TAILQ_CONCAT
(
&
reset
,
&
T
->
wheel
[
i
][
j
]);
}
}
TAILQ_CONCAT
(
&
reset
,
&
T
->
expired
);
TAILQ_FOREACH
(
to
,
&
reset
,
tqe
)
{
to
->
timeouts
=
NULL
;
to
->
pending
=
NULL
;
}
}
/* timeouts_reset() */
TIMEOUT_PUBLIC
void
timeouts_close
(
struct
timeouts
*
T
)
{
/*
* NOTE: Delete installed timeouts so timeout_pending() and
* timeout_expired() worked as expected.
*/
timeouts_reset
(
T
);
free
(
T
);
}
/* timeouts_close() */
TIMEOUT_PUBLIC
timeout_t
timeouts_hz
(
struct
timeouts
*
T
)
{
return
T
->
hertz
;
}
/* timeouts_hz() */
TIMEOUT_PUBLIC
void
timeouts_del
(
struct
timeouts
*
T
,
struct
timeout
*
to
)
{
if
(
to
->
pending
)
{
if
(
to
->
pending
!=
&
T
->
expired
&&
TAILQ_EMPTY
(
to
->
pending
))
{
...
...
timeout.h
View file @
d453fc96
...
...
@@ -146,12 +146,15 @@ TIMEOUT_PUBLIC void timeout_del(struct timeout *);
struct
timeouts
;
TIMEOUT_PUBLIC
struct
timeouts
*
timeouts_open
(
timeout_t
);
TIMEOUT_PUBLIC
struct
timeouts
*
timeouts_open
(
timeout_t
,
int
*
);
/* open a new timing wheel, setting optional HZ (for float conversions) */
TIMEOUT_PUBLIC
void
timeouts_close
(
struct
timeouts
*
);
/* destroy timing wheel */
TIMEOUT_PUBLIC
timeout_t
timeouts_hz
(
struct
timeouts
*
);
/* return HZ setting (for float conversions) */
TIMEOUT_PUBLIC
void
timeouts_update
(
struct
timeouts
*
,
timeout_t
);
/* update timing wheel with current absolute time */
...
...
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