mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 06:25:31 +00:00
update
This commit is contained in:
@@ -42,6 +42,7 @@ main(int argc, char *argv[]) {
|
|||||||
mem_context_t mctx = NULL;
|
mem_context_t mctx = NULL;
|
||||||
task_manager_t manager = NULL;
|
task_manager_t manager = NULL;
|
||||||
task_t t1 = NULL, t2 = NULL;
|
task_t t1 = NULL, t2 = NULL;
|
||||||
|
task_t t3 = NULL, t4 = NULL;
|
||||||
generic_event_t event;
|
generic_event_t event;
|
||||||
unsigned int workers;
|
unsigned int workers;
|
||||||
|
|
||||||
@@ -57,27 +58,45 @@ main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
INSIST(task_create(manager, "1", my_shutdown, 0, &t1));
|
INSIST(task_create(manager, "1", my_shutdown, 0, &t1));
|
||||||
INSIST(task_create(manager, "2", my_shutdown, 0, &t2));
|
INSIST(task_create(manager, "2", my_shutdown, 0, &t2));
|
||||||
event = event_get(mctx, 1, my_callback, sizeof *event);
|
INSIST(task_create(manager, "3", my_shutdown, 0, &t3));
|
||||||
task_send_event(t1, event);
|
INSIST(task_create(manager, "4", my_shutdown, 0, &t4));
|
||||||
event = event_get(mctx, 1, my_callback, sizeof *event);
|
|
||||||
task_send_event(t2, event);
|
event = event_get(mctx, 1, my_callback, sizeof *event);
|
||||||
event = event_get(mctx, 1, my_callback, sizeof *event);
|
task_send_event(t1, event);
|
||||||
task_send_event(t1, event);
|
event = event_get(mctx, 1, my_callback, sizeof *event);
|
||||||
event = event_get(mctx, 1, my_callback, sizeof *event);
|
task_send_event(t1, event);
|
||||||
task_send_event(t2, event);
|
event = event_get(mctx, 1, my_callback, sizeof *event);
|
||||||
event = event_get(mctx, 1, my_callback, sizeof *event);
|
task_send_event(t1, event);
|
||||||
task_send_event(t1, event);
|
event = event_get(mctx, 1, my_callback, sizeof *event);
|
||||||
event = event_get(mctx, 1, my_callback, sizeof *event);
|
task_send_event(t1, event);
|
||||||
task_send_event(t2, event);
|
event = event_get(mctx, 1, my_callback, sizeof *event);
|
||||||
event = event_get(mctx, 1, my_callback, sizeof *event);
|
task_send_event(t1, event);
|
||||||
task_send_event(t1, event);
|
event = event_get(mctx, 1, my_callback, sizeof *event);
|
||||||
event = event_get(mctx, 1, my_callback, sizeof *event);
|
task_send_event(t1, event);
|
||||||
task_send_event(t2, event);
|
event = event_get(mctx, 1, my_callback, sizeof *event);
|
||||||
|
task_send_event(t1, event);
|
||||||
|
event = event_get(mctx, 1, my_callback, sizeof *event);
|
||||||
|
task_send_event(t1, event);
|
||||||
|
event = event_get(mctx, 1, my_callback, sizeof *event);
|
||||||
|
task_send_event(t1, event);
|
||||||
|
event = event_get(mctx, 1, my_callback, sizeof *event);
|
||||||
|
task_send_event(t2, event);
|
||||||
|
event = event_get(mctx, 1, my_callback, sizeof *event);
|
||||||
|
task_send_event(t3, event);
|
||||||
|
event = event_get(mctx, 1, my_callback, sizeof *event);
|
||||||
|
task_send_event(t4, event);
|
||||||
|
event = event_get(mctx, 1, my_callback, sizeof *event);
|
||||||
|
task_send_event(t2, event);
|
||||||
|
event = event_get(mctx, 1, my_callback, sizeof *event);
|
||||||
|
task_send_event(t3, event);
|
||||||
|
event = event_get(mctx, 1, my_callback, sizeof *event);
|
||||||
|
task_send_event(t4, event);
|
||||||
|
|
||||||
task_shutdown(t1);
|
|
||||||
task_shutdown(t2);
|
|
||||||
task_detach(&t1);
|
task_detach(&t1);
|
||||||
task_detach(&t2);
|
task_detach(&t2);
|
||||||
|
task_detach(&t3);
|
||||||
|
task_detach(&t4);
|
||||||
|
|
||||||
printf("destroy\n");
|
printf("destroy\n");
|
||||||
task_manager_destroy(&manager);
|
task_manager_destroy(&manager);
|
||||||
printf("destroyed\n");
|
printf("destroyed\n");
|
||||||
|
@@ -57,6 +57,7 @@ void * event_get(mem_context_t,
|
|||||||
size_t);
|
size_t);
|
||||||
void event_put(void *);
|
void event_put(void *);
|
||||||
|
|
||||||
|
|
||||||
/***
|
/***
|
||||||
*** Tasks.
|
*** Tasks.
|
||||||
***/
|
***/
|
||||||
|
@@ -22,7 +22,7 @@ typedef pthread_cond_t os_condition_t;
|
|||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
Error! Condition variables are not meaningful for a non-threaded program.
|
#error Condition variables are not meaningful for a non-threaded program.
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -14,6 +14,10 @@ typedef pthread_t os_thread_t;
|
|||||||
== 0)
|
== 0)
|
||||||
#define os_thread_detach(t) INSIST(pthread_detach((t)) == 0)
|
#define os_thread_detach(t) INSIST(pthread_detach((t)) == 0)
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
#error Threads are not meaningful for a non-threaded program.
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* THREAD_H */
|
#endif /* THREAD_H */
|
||||||
|
@@ -11,6 +11,11 @@
|
|||||||
#define VALID_TASK(t) ((t) != NULL && \
|
#define VALID_TASK(t) ((t) != NULL && \
|
||||||
(t)->magic == TASK_MAGIC)
|
(t)->magic == TASK_MAGIC)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We use macros instead of calling the os_ routines
|
||||||
|
* directly because the capital letters make the
|
||||||
|
* locking stand out.
|
||||||
|
*/
|
||||||
#define LOCK(lp) os_mutex_lock((lp))
|
#define LOCK(lp) os_mutex_lock((lp))
|
||||||
#define UNLOCK(lp) os_mutex_unlock((lp))
|
#define UNLOCK(lp) os_mutex_unlock((lp))
|
||||||
#define WAIT(cvp, lp) os_condition_wait((cvp), (lp))
|
#define WAIT(cvp, lp) os_condition_wait((cvp), (lp))
|
||||||
|
Reference in New Issue
Block a user