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
efb357a4
Commit
efb357a4
authored
Jan 22, 2016
by
Nick Mathewson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement a function to iterate over all pending timeouts
Libevent needed this, and I expect that others will too.
parent
bafeec9c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
timeout.c
timeout.c
+18
-0
timeout.h
timeout.h
+4
-0
No files found.
timeout.c
View file @
efb357a4
...
@@ -579,6 +579,24 @@ static struct timeout *timeouts_min(struct timeouts *T) {
...
@@ -579,6 +579,24 @@ static struct timeout *timeouts_min(struct timeouts *T) {
} \
} \
} while (0)
} while (0)
TIMEOUT_PUBLIC
int
timeouts_foreach
(
struct
timeouts
*
T
,
int
(
*
fp
)(
struct
timeout
*
,
void
*
),
void
*
cb_arg
)
{
struct
timeout
*
to
=
NULL
;
int
rv
;
unsigned
i
,
j
;
for
(
i
=
0
;
i
<
countof
(
T
->
wheel
);
i
++
)
{
for
(
j
=
0
;
j
<
countof
(
T
->
wheel
[
i
]);
j
++
)
{
TAILQ_FOREACH
(
to
,
&
T
->
wheel
[
i
][
j
],
tqe
)
{
rv
=
fp
(
to
,
cb_arg
);
if
(
rv
)
return
rv
;
}
}
}
return
0
;
}
/* timeouts_foreach */
TIMEOUT_PUBLIC
bool
timeouts_check
(
struct
timeouts
*
T
,
FILE
*
fp
)
{
TIMEOUT_PUBLIC
bool
timeouts_check
(
struct
timeouts
*
T
,
FILE
*
fp
)
{
timeout_t
timeout
;
timeout_t
timeout
;
struct
timeout
*
to
;
struct
timeout
*
to
;
...
...
timeout.h
View file @
efb357a4
...
@@ -188,6 +188,10 @@ TIMEOUT_PUBLIC bool timeouts_expired(struct timeouts *);
...
@@ -188,6 +188,10 @@ TIMEOUT_PUBLIC bool timeouts_expired(struct timeouts *);
TIMEOUT_PUBLIC
bool
timeouts_check
(
struct
timeouts
*
,
FILE
*
);
TIMEOUT_PUBLIC
bool
timeouts_check
(
struct
timeouts
*
,
FILE
*
);
/* return true if invariants hold. describes failures to optional file handle. */
/* return true if invariants hold. describes failures to optional file handle. */
TIMEOUT_PUBLIC
int
timeouts_foreach
(
struct
timeouts
*
,
int
(
*
fn
)(
struct
timeout
*
,
void
*
),
void
*
);
/* Run fn(timeout,arg) on every pending or expired timeout in the wheel. If
* any iteration returns nonzero, return the nonzero value immediately and
* stop looping. */
/*
/*
* B O N U S W H E E L I N T E R F A C E S
* B O N U S W H E E L I N T E R F A C E S
...
...
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