2
* ivykis, an event handling library
3
* Copyright (C) 2010 Lennert Buytenhek
4
* Dedicated to Marija Kulikova.
6
* This library is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU Lesser General Public License version
8
* 2.1 as published by the Free Software Foundation.
10
* This library is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU Lesser General Public License version 2.1 for more details.
15
* You should have received a copy of the GNU Lesser General Public
16
* License version 2.1 along with this library; if not, write to the
17
* Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
18
* Boston, MA 02110-1301, USA.
24
#include <iv_thread.h>
27
static struct iv_work_pool pool;
28
static struct iv_work_item item_a;
29
static struct iv_work_item item_b;
30
static struct iv_work_item item_c;
31
static struct iv_work_item item_d;
32
static int item_count;
34
static void work(void *cookie)
38
printf("performing work item %s in thread %p\n",
39
task, (void *)pthread_self());
44
static void work_complete(void *cookie)
48
printf("notification that work item %s is complete\n", task);
51
if (item_count == 3) {
52
printf("putting pool\n");
53
iv_work_pool_put(&pool);
61
iv_thread_set_debug_state(1);
63
IV_WORK_POOL_INIT(&pool);
65
iv_work_pool_create(&pool);
67
IV_WORK_ITEM_INIT(&item_a);
70
item_a.completion = work_complete;
71
iv_work_pool_submit_work(&pool, &item_a);
73
IV_WORK_ITEM_INIT(&item_b);
76
item_b.completion = work_complete;
77
iv_work_pool_submit_work(&pool, &item_b);
79
IV_WORK_ITEM_INIT(&item_c);
82
item_c.completion = work_complete;
83
iv_work_pool_submit_work(&pool, &item_c);
85
IV_WORK_ITEM_INIT(&item_d);
88
item_d.completion = work_complete;
89
iv_work_pool_submit_work(&pool, &item_d);