Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
ISC Open Source Projects
BIND
Commits
c92ba071
Commit
c92ba071
authored
Oct 21, 1998
by
Bob Halley
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more renaming
parent
5f74ac33
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
201 additions
and
200 deletions
+201
-200
bin/tests/task_test.c
bin/tests/task_test.c
+64
-64
bin/tests/timer_test.c
bin/tests/timer_test.c
+13
-13
lib/isc/include/isc/task.h
lib/isc/include/isc/task.h
+39
-38
lib/isc/include/isc/timer.h
lib/isc/include/isc/timer.h
+3
-3
lib/isc/task.c
lib/isc/task.c
+65
-65
lib/isc/timer.c
lib/isc/timer.c
+17
-17
No files found.
bin/tests/task_test.c
View file @
c92ba071
...
...
@@ -14,7 +14,7 @@
mem_context_t
mctx
=
NULL
;
static
isc_boolean_t
my_callback
(
task_t
task
,
task
_event_t
event
)
my_callback
(
isc_
task_t
task
,
isc
_event_t
event
)
{
int
i
,
j
;
char
*
name
=
event
->
arg
;
...
...
@@ -28,7 +28,7 @@ my_callback(task_t task, task_event_t event)
}
static
isc_boolean_t
my_shutdown
(
task_t
task
,
task
_event_t
event
)
{
my_shutdown
(
isc_
task_t
task
,
isc
_event_t
event
)
{
char
*
name
=
event
->
arg
;
printf
(
"shutdown %s (%p)
\n
"
,
name
,
task
);
...
...
@@ -36,7 +36,7 @@ my_shutdown(task_t task, task_event_t event) {
}
static
isc_boolean_t
my_tick
(
task_t
task
,
task
_event_t
event
)
my_tick
(
isc_
task_t
task
,
isc
_event_t
event
)
{
char
*
name
=
event
->
arg
;
...
...
@@ -46,10 +46,10 @@ my_tick(task_t task, task_event_t event)
void
main
(
int
argc
,
char
*
argv
[])
{
task_manage
r_t
manager
=
NULL
;
task_t
t1
=
NULL
,
t2
=
NULL
;
task_t
t3
=
NULL
,
t4
=
NULL
;
task
_event_t
event
;
isc_taskmg
r_t
manager
=
NULL
;
isc_
task_t
t1
=
NULL
,
t2
=
NULL
;
isc_
task_t
t3
=
NULL
,
t4
=
NULL
;
isc
_event_t
event
;
unsigned
int
workers
;
isc_timermgr_t
timgr
;
isc_timer_t
ti1
,
ti2
;
...
...
@@ -63,12 +63,12 @@ main(int argc, char *argv[]) {
INSIST
(
mem_context_create
(
0
,
0
,
&
mctx
)
==
0
);
INSIST
(
task_manage
r_create
(
mctx
,
workers
,
0
,
&
manager
)
==
workers
);
INSIST
(
isc_taskmg
r_create
(
mctx
,
workers
,
0
,
&
manager
)
==
workers
);
INSIST
(
task_create
(
manager
,
my_shutdown
,
"1"
,
0
,
&
t1
));
INSIST
(
task_create
(
manager
,
my_shutdown
,
"2"
,
0
,
&
t2
));
INSIST
(
task_create
(
manager
,
my_shutdown
,
"3"
,
0
,
&
t3
));
INSIST
(
task_create
(
manager
,
my_shutdown
,
"4"
,
0
,
&
t4
));
INSIST
(
isc_
task_create
(
manager
,
my_shutdown
,
"1"
,
0
,
&
t1
));
INSIST
(
isc_
task_create
(
manager
,
my_shutdown
,
"2"
,
0
,
&
t2
));
INSIST
(
isc_
task_create
(
manager
,
my_shutdown
,
"3"
,
0
,
&
t3
));
INSIST
(
isc_
task_create
(
manager
,
my_shutdown
,
"4"
,
0
,
&
t4
));
timgr
=
NULL
;
INSIST
(
isc_timermgr_create
(
mctx
,
&
timgr
)
==
ISC_R_SUCCESS
);
...
...
@@ -89,64 +89,64 @@ main(int argc, char *argv[]) {
printf
(
"task 2 = %p
\n
"
,
t2
);
sleep
(
2
);
event
=
task
_event_allocate
(
mctx
,
main
,
1
,
my_callback
,
"1"
,
sizeof
*
event
);
task_send
_event
(
t1
,
&
event
);
event
=
task
_event_allocate
(
mctx
,
main
,
1
,
my_callback
,
"1"
,
sizeof
*
event
);
task_send
_event
(
t1
,
&
event
);
event
=
task
_event_allocate
(
mctx
,
main
,
1
,
my_callback
,
"1"
,
sizeof
*
event
);
task_send
_event
(
t1
,
&
event
);
event
=
task
_event_allocate
(
mctx
,
main
,
1
,
my_callback
,
"1"
,
sizeof
*
event
);
task_send
_event
(
t1
,
&
event
);
event
=
task
_event_allocate
(
mctx
,
main
,
1
,
my_callback
,
"1"
,
sizeof
*
event
);
task_send
_event
(
t1
,
&
event
);
event
=
task
_event_allocate
(
mctx
,
main
,
1
,
my_callback
,
"1"
,
sizeof
*
event
);
task_send
_event
(
t1
,
&
event
);
event
=
task
_event_allocate
(
mctx
,
main
,
1
,
my_callback
,
"1"
,
sizeof
*
event
);
task_send
_event
(
t1
,
&
event
);
event
=
task
_event_allocate
(
mctx
,
main
,
1
,
my_callback
,
"1"
,
sizeof
*
event
);
task_send
_event
(
t1
,
&
event
);
event
=
task
_event_allocate
(
mctx
,
main
,
1
,
my_callback
,
"1"
,
sizeof
*
event
);
task_send
_event
(
t1
,
&
event
);
event
=
task
_event_allocate
(
mctx
,
main
,
1
,
my_callback
,
"2"
,
sizeof
*
event
);
task_send
_event
(
t2
,
&
event
);
event
=
task
_event_allocate
(
mctx
,
main
,
1
,
my_callback
,
"3"
,
sizeof
*
event
);
task_send
_event
(
t3
,
&
event
);
event
=
task
_event_allocate
(
mctx
,
main
,
1
,
my_callback
,
"4"
,
sizeof
*
event
);
task_send
_event
(
t4
,
&
event
);
event
=
task
_event_allocate
(
mctx
,
main
,
1
,
my_callback
,
"2"
,
sizeof
*
event
);
task_send
_event
(
t2
,
&
event
);
event
=
task
_event_allocate
(
mctx
,
main
,
1
,
my_callback
,
"3"
,
sizeof
*
event
);
task_send
_event
(
t3
,
&
event
);
event
=
task
_event_allocate
(
mctx
,
main
,
1
,
my_callback
,
"4"
,
sizeof
*
event
);
task_send
_event
(
t4
,
&
event
);
task_purge
_events
(
t3
,
NULL
,
0
);
task_detach
(
&
t1
);
task_detach
(
&
t2
);
task_detach
(
&
t3
);
task_detach
(
&
t4
);
event
=
isc
_event_allocate
(
mctx
,
main
,
1
,
my_callback
,
"1"
,
sizeof
*
event
);
isc_
task_send
(
t1
,
&
event
);
event
=
isc
_event_allocate
(
mctx
,
main
,
1
,
my_callback
,
"1"
,
sizeof
*
event
);
isc_
task_send
(
t1
,
&
event
);
event
=
isc
_event_allocate
(
mctx
,
main
,
1
,
my_callback
,
"1"
,
sizeof
*
event
);
isc_
task_send
(
t1
,
&
event
);
event
=
isc
_event_allocate
(
mctx
,
main
,
1
,
my_callback
,
"1"
,
sizeof
*
event
);
isc_
task_send
(
t1
,
&
event
);
event
=
isc
_event_allocate
(
mctx
,
main
,
1
,
my_callback
,
"1"
,
sizeof
*
event
);
isc_
task_send
(
t1
,
&
event
);
event
=
isc
_event_allocate
(
mctx
,
main
,
1
,
my_callback
,
"1"
,
sizeof
*
event
);
isc_
task_send
(
t1
,
&
event
);
event
=
isc
_event_allocate
(
mctx
,
main
,
1
,
my_callback
,
"1"
,
sizeof
*
event
);
isc_
task_send
(
t1
,
&
event
);
event
=
isc
_event_allocate
(
mctx
,
main
,
1
,
my_callback
,
"1"
,
sizeof
*
event
);
isc_
task_send
(
t1
,
&
event
);
event
=
isc
_event_allocate
(
mctx
,
main
,
1
,
my_callback
,
"1"
,
sizeof
*
event
);
isc_
task_send
(
t1
,
&
event
);
event
=
isc
_event_allocate
(
mctx
,
main
,
1
,
my_callback
,
"2"
,
sizeof
*
event
);
isc_
task_send
(
t2
,
&
event
);
event
=
isc
_event_allocate
(
mctx
,
main
,
1
,
my_callback
,
"3"
,
sizeof
*
event
);
isc_
task_send
(
t3
,
&
event
);
event
=
isc
_event_allocate
(
mctx
,
main
,
1
,
my_callback
,
"4"
,
sizeof
*
event
);
isc_
task_send
(
t4
,
&
event
);
event
=
isc
_event_allocate
(
mctx
,
main
,
1
,
my_callback
,
"2"
,
sizeof
*
event
);
isc_
task_send
(
t2
,
&
event
);
event
=
isc
_event_allocate
(
mctx
,
main
,
1
,
my_callback
,
"3"
,
sizeof
*
event
);
isc_
task_send
(
t3
,
&
event
);
event
=
isc
_event_allocate
(
mctx
,
main
,
1
,
my_callback
,
"4"
,
sizeof
*
event
);
isc_
task_send
(
t4
,
&
event
);
isc_
task_purge
(
t3
,
NULL
,
0
);
isc_
task_detach
(
&
t1
);
isc_
task_detach
(
&
t2
);
isc_
task_detach
(
&
t3
);
isc_
task_detach
(
&
t4
);
sleep
(
10
);
printf
(
"destroy
\n
"
);
isc_timer_detach
(
&
ti1
);
isc_timer_detach
(
&
ti2
);
isc_timermgr_destroy
(
&
timgr
);
task_manage
r_destroy
(
&
manager
);
isc_taskmg
r_destroy
(
&
manager
);
printf
(
"destroyed
\n
"
);
mem_stats
(
mctx
,
stdout
);
...
...
bin/tests/timer_test.c
View file @
c92ba071
...
...
@@ -12,12 +12,12 @@
#include <isc/timer.h>
mem_context_t
mctx
=
NULL
;
task_t
t1
,
t2
,
t3
;
isc_
task_t
t1
,
t2
,
t3
;
isc_timer_t
ti1
,
ti2
,
ti3
;
int
tick_count
=
0
;
static
isc_boolean_t
shutdown_task
(
task_t
task
,
task
_event_t
event
)
{
shutdown_task
(
isc_
task_t
task
,
isc
_event_t
event
)
{
char
*
name
=
event
->
arg
;
printf
(
"task %p shutdown %s
\n
"
,
task
,
name
);
...
...
@@ -25,7 +25,7 @@ shutdown_task(task_t task, task_event_t event) {
}
static
isc_boolean_t
tick
(
task_t
task
,
task
_event_t
event
)
tick
(
isc_
task_t
task
,
isc
_event_t
event
)
{
char
*
name
=
event
->
arg
;
...
...
@@ -56,7 +56,7 @@ tick(task_t task, task_event_t event)
}
static
isc_boolean_t
timeout
(
task_t
task
,
task
_event_t
event
)
timeout
(
isc_
task_t
task
,
isc
_event_t
event
)
{
char
*
name
=
event
->
arg
;
char
*
type
;
...
...
@@ -79,7 +79,7 @@ timeout(task_t task, task_event_t event)
void
main
(
int
argc
,
char
*
argv
[])
{
task_manage
r_t
manager
=
NULL
;
isc_taskmg
r_t
manager
=
NULL
;
isc_timermgr_t
timgr
=
NULL
;
unsigned
int
workers
;
os_time_t
expires
,
interval
,
now
;
...
...
@@ -91,10 +91,10 @@ main(int argc, char *argv[]) {
printf
(
"%d workers
\n
"
,
workers
);
INSIST
(
mem_context_create
(
0
,
0
,
&
mctx
)
==
0
);
INSIST
(
task_manage
r_create
(
mctx
,
workers
,
0
,
&
manager
)
==
workers
);
INSIST
(
task_create
(
manager
,
shutdown_task
,
"1"
,
0
,
&
t1
));
INSIST
(
task_create
(
manager
,
shutdown_task
,
"2"
,
0
,
&
t2
));
INSIST
(
task_create
(
manager
,
shutdown_task
,
"3"
,
0
,
&
t3
));
INSIST
(
isc_taskmg
r_create
(
mctx
,
workers
,
0
,
&
manager
)
==
workers
);
INSIST
(
isc_
task_create
(
manager
,
shutdown_task
,
"1"
,
0
,
&
t1
));
INSIST
(
isc_
task_create
(
manager
,
shutdown_task
,
"2"
,
0
,
&
t2
));
INSIST
(
isc_
task_create
(
manager
,
shutdown_task
,
"3"
,
0
,
&
t3
));
INSIST
(
isc_timermgr_create
(
mctx
,
&
timgr
)
==
ISC_R_SUCCESS
);
printf
(
"task 1: %p
\n
"
,
t1
);
...
...
@@ -123,9 +123,9 @@ main(int argc, char *argv[]) {
INSIST
(
isc_timer_create
(
timgr
,
isc_timertype_once
,
expires
,
interval
,
t3
,
timeout
,
"3"
,
&
ti3
)
==
ISC_R_SUCCESS
);
task_detach
(
&
t1
);
task_detach
(
&
t2
);
task_detach
(
&
t3
);
isc_
task_detach
(
&
t1
);
isc_
task_detach
(
&
t2
);
isc_
task_detach
(
&
t3
);
sleep
(
15
);
printf
(
"destroy
\n
"
);
...
...
@@ -134,7 +134,7 @@ main(int argc, char *argv[]) {
isc_timer_detach
(
&
ti3
);
sleep
(
2
);
isc_timermgr_destroy
(
&
timgr
);
task_manage
r_destroy
(
&
manager
);
isc_taskmg
r_destroy
(
&
manager
);
printf
(
"destroyed
\n
"
);
mem_stats
(
mctx
,
stdout
);
...
...
lib/isc/include/isc/task.h
View file @
c92ba071
#ifndef TASK_H
#define TASK_H 1
#ifndef
ISC_
TASK_H
#define
ISC_
TASK_H 1
#include <stddef.h>
...
...
@@ -14,9 +14,9 @@
*** Core Types.
***/
typedef
struct
task
_event
*
task
_event_t
;
typedef
struct
task
*
task_t
;
typedef
struct
task_manager
*
task_manage
r_t
;
typedef
struct
isc
_event
*
isc
_event_t
;
typedef
struct
isc_
task
*
isc_
task_t
;
typedef
struct
isc_taskmgr
*
isc_taskmg
r_t
;
/***
...
...
@@ -28,64 +28,65 @@ typedef struct task_manager * task_manager_t;
*
* Type 0 means "any type".
*/
typedef
int
task
_eventtype_t
;
typedef
int
isc
_eventtype_t
;
typedef
isc_boolean_t
(
*
task
_
action_t
)(
task_t
,
task
_event_t
);
typedef
isc_boolean_t
(
*
isc_
taskaction_t
)(
isc_
task_t
,
isc
_event_t
);
/*
* This structure is public because "subclassing" it may be useful when
* defining new event types.
*/
struct
task
_event
{
struct
isc
_event
{
mem_context_t
mctx
;
size_t
size
;
void
*
sender
;
task
_eventtype_t
type
;
task
_
action_t
action
;
isc
_eventtype_t
type
;
isc_
taskaction_t
action
;
void
*
arg
;
LINK
(
struct
task
_event
)
link
;
LINK
(
struct
isc
_event
)
link
;
};
#define TASK
_
EVENT_ANYEVENT 0
#define TASK
_
EVENT_SHUTDOWN (-1)
#define
ISC_
TASKEVENT_ANYEVENT 0
#define
ISC_
TASKEVENT_SHUTDOWN (-1)
typedef
LIST
(
struct
task
_event
)
task
_eventlist_t
;
typedef
LIST
(
struct
isc
_event
)
isc
_eventlist_t
;
task
_event_t
task
_event_allocate
(
mem_context_t
,
void
*
,
task
_eventtype_t
,
task
_
action_t
,
void
*
arg
,
size_t
);
void
task
_event_free
(
task
_event_t
*
);
isc
_event_t
isc
_event_allocate
(
mem_context_t
,
void
*
,
isc
_eventtype_t
,
isc_
taskaction_t
,
void
*
arg
,
size_t
);
void
isc
_event_free
(
isc
_event_t
*
);
/***
*** Tasks.
***/
isc_boolean_t
task_create
(
task_manage
r_t
,
task
_
action_t
,
isc_boolean_t
isc_
task_create
(
isc_taskmg
r_t
,
isc_
taskaction_t
,
void
*
,
unsigned
int
,
task_t
*
);
void
task_attach
(
task_t
,
task_t
*
);
void
task_detach
(
task_t
*
);
isc_boolean_t
task_send_event
(
task_t
,
task_event_t
*
);
void
task_purge_events
(
task_t
,
void
*
,
task_eventtype_t
);
void
task_shutdown
(
task_t
);
void
task_destroy
(
task_t
*
);
isc_task_t
*
);
void
isc_task_attach
(
isc_task_t
,
isc_task_t
*
);
void
isc_task_detach
(
isc_task_t
*
);
isc_boolean_t
isc_task_send
(
isc_task_t
,
isc_event_t
*
);
void
isc_task_purge
(
isc_task_t
,
void
*
,
isc_eventtype_t
);
void
isc_task_shutdown
(
isc_task_t
);
void
isc_task_destroy
(
isc_task_t
*
);
/***
*** Task Manager.
***/
unsigned
int
task_manage
r_create
(
mem_context_t
,
unsigned
int
,
unsigned
int
,
task_manage
r_t
*
);
void
task_manager_destroy
(
task_manage
r_t
*
);
unsigned
int
isc_taskmg
r_create
(
mem_context_t
,
unsigned
int
,
unsigned
int
,
isc_taskmg
r_t
*
);
void
isc_taskmgr_destroy
(
isc_taskmg
r_t
*
);
#endif
/* TASK_H */
#endif
/*
ISC_
TASK_H */
lib/isc/include/isc/timer.h
View file @
c92ba071
...
...
@@ -72,7 +72,7 @@ typedef enum {
}
isc_timertype_t
;
typedef
struct
isc_timerevent
{
struct
task
_event
common
;
struct
isc
_event
common
;
/* XXX Anything else? XXX */
}
*
isc_timerevent_t
;
...
...
@@ -93,8 +93,8 @@ isc_timer_create(isc_timermgr_t manager,
isc_timertype_t
type
,
os_time_t
expires
,
os_time_t
interval
,
task_t
task
,
task
_
action_t
action
,
isc_
task_t
task
,
isc_
taskaction_t
action
,
void
*
arg
,
isc_timer_t
*
timerp
);
/*
...
...
lib/isc/task.c
View file @
c92ba071
...
...
@@ -26,7 +26,7 @@
#define WAIT(cvp, lp) INSIST(os_condition_wait((cvp), (lp)))
#define BROADCAST(cvp) INSIST(os_condition_broadcast((cvp)))
#ifdef TASK_TRACE
#ifdef
ISC_
TASK_TRACE
#define XTRACE(m) printf("%s task %p thread %p\n", (m), \
task, os_thread_self())
#else
...
...
@@ -47,36 +47,36 @@ typedef enum {
#define VALID_TASK(t) ((t) != NULL && \
(t)->magic == TASK_MAGIC)
struct
task
{
struct
isc_
task
{
/* Not locked. */
unsigned
int
magic
;
task_manage
r_t
manager
;
isc_taskmg
r_t
manager
;
os_mutex_t
lock
;
/* Locked by task lock. */
task_state_t
state
;
unsigned
int
references
;
task
_eventlist_t
events
;
isc
_eventlist_t
events
;
unsigned
int
quantum
;
isc_boolean_t
enqueue_allowed
;
task
_event_t
shutdown_event
;
isc
_event_t
shutdown_event
;
/* Locked by task manager lock. */
LINK
(
struct
task
)
link
;
LINK
(
struct
task
)
ready_link
;
LINK
(
struct
isc_
task
)
link
;
LINK
(
struct
isc_
task
)
ready_link
;
};
#define TASK_MANAGER_MAGIC 0x54534B4DU
/* TSKM. */
#define VALID_MANAGER(m) ((m) != NULL && \
(m)->magic == TASK_MANAGER_MAGIC)
struct
task_manage
r
{
struct
isc_taskmg
r
{
/* Not locked. */
unsigned
int
magic
;
mem_context_t
mctx
;
os_mutex_t
lock
;
/* Locked by task manager lock. */
unsigned
int
default_quantum
;
LIST
(
struct
task
)
tasks
;
LIST
(
struct
task
)
ready_tasks
;
LIST
(
struct
isc_
task
)
tasks
;
LIST
(
struct
isc_
task
)
ready_tasks
;
os_condition_t
work_available
;
isc_boolean_t
exiting
;
unsigned
int
workers
;
...
...
@@ -91,11 +91,11 @@ struct task_manager {
*** Events.
***/
static
inline
task
_event_t
event_allocate
(
mem_context_t
mctx
,
void
*
sender
,
task
_eventtype_t
type
,
task
_
action_t
action
,
void
*
arg
,
size_t
size
)
static
inline
isc
_event_t
event_allocate
(
mem_context_t
mctx
,
void
*
sender
,
isc
_eventtype_t
type
,
isc_
taskaction_t
action
,
void
*
arg
,
size_t
size
)
{
task
_event_t
event
;
isc
_event_t
event
;
event
=
mem_get
(
mctx
,
size
);
if
(
event
==
NULL
)
...
...
@@ -110,11 +110,11 @@ event_allocate(mem_context_t mctx, void *sender, task_eventtype_t type,
return
(
event
);
}
task
_event_t
task
_event_allocate
(
mem_context_t
mctx
,
void
*
sender
,
task
_eventtype_t
type
,
task
_
action_t
action
,
void
*
arg
,
size_t
size
)
isc
_event_t
isc
_event_allocate
(
mem_context_t
mctx
,
void
*
sender
,
isc
_eventtype_t
type
,
isc_
taskaction_t
action
,
void
*
arg
,
size_t
size
)
{
if
(
size
<
sizeof
(
struct
task
_event
))
if
(
size
<
sizeof
(
struct
isc
_event
))
return
(
NULL
);
if
(
type
<
0
)
return
(
NULL
);
...
...
@@ -125,8 +125,8 @@ task_event_allocate(mem_context_t mctx, void *sender, task_eventtype_t type,
}
void
task
_event_free
(
task
_event_t
*
eventp
)
{
task
_event_t
event
;
isc
_event_free
(
isc
_event_t
*
eventp
)
{
isc
_event_t
event
;
REQUIRE
(
eventp
!=
NULL
);
event
=
*
eventp
;
...
...
@@ -142,8 +142,8 @@ task_event_free(task_event_t *eventp) {
***/
static
void
task_free
(
task_t
task
)
{
task_manage
r_t
manager
=
task
->
manager
;
task_free
(
isc_
task_t
task
)
{
isc_taskmg
r_t
manager
=
task
->
manager
;
XTRACE
(
"free task"
);
REQUIRE
(
EMPTY
(
task
->
events
));
...
...
@@ -162,16 +162,16 @@ task_free(task_t task) {
UNLOCK
(
&
manager
->
lock
);
(
void
)
os_mutex_destroy
(
&
task
->
lock
);
if
(
task
->
shutdown_event
!=
NULL
)
task
_event_free
(
&
task
->
shutdown_event
);
isc
_event_free
(
&
task
->
shutdown_event
);
task
->
magic
=
0
;
mem_put
(
manager
->
mctx
,
task
,
sizeof
*
task
);
}
isc_boolean_t
task_create
(
task_manage
r_t
manager
,
task
_
action_t
shutdown_action
,
void
*
shutdown_arg
,
unsigned
int
quantum
,
task_t
*
taskp
)
isc_
task_create
(
isc_taskmg
r_t
manager
,
isc_
taskaction_t
shutdown_action
,
void
*
shutdown_arg
,
unsigned
int
quantum
,
isc_
task_t
*
taskp
)
{
task_t
task
;
isc_
task_t
task
;
REQUIRE
(
VALID_MANAGER
(
manager
));
REQUIRE
(
taskp
!=
NULL
&&
*
taskp
==
NULL
);
...
...
@@ -193,7 +193,7 @@ task_create(task_manager_t manager, task_action_t shutdown_action,
task
->
enqueue_allowed
=
ISC_TRUE
;
task
->
shutdown_event
=
event_allocate
(
manager
->
mctx
,
NULL
,
TASK
_
EVENT_SHUTDOWN
,
ISC_
TASKEVENT_SHUTDOWN
,
shutdown_action
,
shutdown_arg
,
sizeof
*
task
->
shutdown_event
);
...
...
@@ -217,7 +217,7 @@ task_create(task_manager_t manager, task_action_t shutdown_action,
}
void
task_attach
(
task_t
task
,
task_t
*
taskp
)
{
isc_
task_attach
(
isc_
task_t
task
,
isc_
task_t
*
taskp
)
{
REQUIRE
(
VALID_TASK
(
task
));
REQUIRE
(
taskp
!=
NULL
&&
*
taskp
==
NULL
);
...
...
@@ -230,11 +230,11 @@ task_attach(task_t task, task_t *taskp) {
}
void
task_detach
(
task_t
*
taskp
)
{
isc_
task_detach
(
isc_
task_t
*
taskp
)
{
isc_boolean_t
free_task
=
ISC_FALSE
;
task_t
task
;
isc_
task_t
task
;
XTRACE
(
"task_detach"
);
XTRACE
(
"
isc_
task_detach"
);
REQUIRE
(
taskp
!=
NULL
);
task
=
*
taskp
;
...
...
@@ -254,10 +254,10 @@ task_detach(task_t *taskp) {
}
isc_boolean_t
task_send
_event
(
task_t
task
,
task
_event_t
*
eventp
)
{
isc_
task_send
(
isc_
task_t
task
,
isc
_event_t
*
eventp
)
{
isc_boolean_t
was_idle
=
ISC_FALSE
;
isc_boolean_t
discard
=
ISC_FALSE
;
task
_event_t
event
;
isc
_event_t
event
;
REQUIRE
(
VALID_TASK
(
task
));
REQUIRE
(
eventp
!=
NULL
);
...
...
@@ -287,14 +287,14 @@ task_send_event(task_t task, task_event_t *eventp) {
UNLOCK
(
&
task
->
lock
);
if
(
discard
)
{
task
_event_free
(
&
event
);
isc
_event_free
(
&
event
);
*
eventp
=
NULL
;
return
(
ISC_TRUE
);
}
if
(
was_idle
)
{
isc_boolean_t
need_wakeup
=
ISC_FALSE
;
task_manage
r_t
manager
;
isc_taskmg
r_t
manager
;
/*
* We need to add this task to the ready queue.
...
...
@@ -339,9 +339,9 @@ task_send_event(task_t task, task_event_t *eventp) {
}
void
task_purge
_events
(
task_t
task
,
void
*
sender
,
task
_eventtype_t
type
)
{
task
_event_t
event
,
next_event
;
task
_eventlist_t
purgeable
;
isc_
task_purge
(
isc_
task_t
task
,
void
*
sender
,
isc
_eventtype_t
type
)
{
isc
_event_t
event
,
next_event
;
isc
_eventlist_t
purgeable
;
REQUIRE
(
VALID_TASK
(
task
));
REQUIRE
(
type
>=
0
);
...
...
@@ -371,19 +371,19 @@ task_purge_events(task_t task, void *sender, task_eventtype_t type) {
event
!=
NULL
;
event
=
next_event
)
{
next_event
=
NEXT
(
event
,
link
);
task
_event_free
(
&
event
);
isc
_event_free
(
&
event
);
}
}
void
task_shutdown
(
task_t
task
)
{
isc_
task_shutdown
(
isc_
task_t
task
)
{
isc_boolean_t
was_idle
=
ISC_FALSE
;
isc_boolean_t
discard
=
ISC_FALSE
;
REQUIRE
(
VALID_TASK
(
task
));
/*
* This routine is very similar to task_send_event() above.
* This routine is very similar to
isc_
task_send_event() above.
*/
LOCK
(
&
task
->
lock
);
...
...
@@ -408,7 +408,7 @@ task_shutdown(task_t task) {
if
(
was_idle
)
{
isc_boolean_t
need_wakeup
=
ISC_FALSE
;
task_manage
r_t
manager
;
isc_taskmg
r_t
manager
;
manager
=
task
->
manager
;
INSIST
(
VALID_MANAGER
(
manager
));
...
...
@@ -424,12 +424,12 @@ task_shutdown(task_t task) {
}