~ubuntu-branches/ubuntu/trusty/syslog-ng/trusty-proposed

« back to all changes in this revision

Viewing changes to lib/ivykis/modules/test/iv_work_test.c

  • Committer: Package Import Robot
  • Author(s): Laszlo Boszormenyi (GCS), Gergely Nagy
  • Date: 2011-10-11 14:30:48 UTC
  • mfrom: (1.3.7)
  • Revision ID: package-import@ubuntu.com-20111011143048-r1iljux9xbvj3lwh
Tags: 3.3.1.dfsg-1
* New upstream release with important fixes from upstream git tree with
  non-free manpages removed.
* Drop syslog-ng.conf(5) (closes: #496521).
* syslog-ng(8) is generated, and does not mention -Q anymore
  (closes: #616069).
* Supports CAP_SYSLOG on recent kernels (closes: #630172).
* Does not use g_timeout_add_seconds anymore (closes: #609154).

[ Gergely Nagy <algernon@madhouse-project.org> ]
* Update debian/copyright to DEP-5 format.
* Simplified the logrotate file by merging identical entries.
* Include local configuration files from /etc/syslog-ng/conf.d/ (Closes:
  #609050).
* Update syslog-ng.conf to be fully 3.3 compliant.
* Compress both source and binaries (except the syslog-ng meta
  package) with xz, instead of gzip.
* Use dpkg triggers to restart syslog-ng when appropriate.
* Include DFSG-free manual pages for all binaries.
* Build with Hardening enabled.
* Mention syslog(3) in /etc/default/syslog-ng, instead of
  <linux/kernel.h> (Closes: #608605)
* Support 'status' in the init script.
  Patch from Peter Eisentraut <petere@debian.org> (Closes: #644458)
* Build-Depend on libevtlog-dev (>= 0.2.12-5~) for correct shlibs.
* Use [linux-any] in Build-Depends instead of hardcoded links.
  (Closes: #634715)
* Use $SYSLOGNG_OPTS in the init script when reloading syslog-ng.
  (Closes: #589081)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * ivykis, an event handling library
 
3
 * Copyright (C) 2010 Lennert Buytenhek
 
4
 * Dedicated to Marija Kulikova.
 
5
 *
 
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.
 
9
 *
 
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.
 
14
 *
 
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.
 
19
 */
 
20
 
 
21
#include <stdio.h>
 
22
#include <stdlib.h>
 
23
#include <iv.h>
 
24
#include <iv_thread.h>
 
25
#include <iv_work.h>
 
26
 
 
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;
 
33
 
 
34
static void work(void *cookie)
 
35
{
 
36
        char *task = cookie;
 
37
 
 
38
        printf("performing work item %s in thread %p\n",
 
39
               task, (void *)pthread_self());
 
40
 
 
41
        sleep(1);
 
42
}
 
43
 
 
44
static void work_complete(void *cookie)
 
45
{
 
46
        char *task = cookie;
 
47
 
 
48
        printf("notification that work item %s is complete\n", task);
 
49
 
 
50
        item_count--;
 
51
        if (item_count == 3) {
 
52
                printf("putting pool\n");
 
53
                iv_work_pool_put(&pool);
 
54
        }
 
55
}
 
56
 
 
57
int main()
 
58
{
 
59
        iv_init();
 
60
 
 
61
        iv_thread_set_debug_state(1);
 
62
 
 
63
        IV_WORK_POOL_INIT(&pool);
 
64
        pool.max_threads = 8;
 
65
        iv_work_pool_create(&pool);
 
66
 
 
67
        IV_WORK_ITEM_INIT(&item_a);
 
68
        item_a.cookie = "a";
 
69
        item_a.work = work;
 
70
        item_a.completion = work_complete;
 
71
        iv_work_pool_submit_work(&pool, &item_a);
 
72
 
 
73
        IV_WORK_ITEM_INIT(&item_b);
 
74
        item_b.cookie = "b";
 
75
        item_b.work = work;
 
76
        item_b.completion = work_complete;
 
77
        iv_work_pool_submit_work(&pool, &item_b);
 
78
 
 
79
        IV_WORK_ITEM_INIT(&item_c);
 
80
        item_c.cookie = "c";
 
81
        item_c.work = work;
 
82
        item_c.completion = work_complete;
 
83
        iv_work_pool_submit_work(&pool, &item_c);
 
84
 
 
85
        IV_WORK_ITEM_INIT(&item_d);
 
86
        item_d.cookie = "d";
 
87
        item_d.work = work;
 
88
        item_d.completion = work_complete;
 
89
        iv_work_pool_submit_work(&pool, &item_d);
 
90
 
 
91
        item_count = 4;
 
92
 
 
93
        iv_main();
 
94
 
 
95
        iv_deinit();
 
96
 
 
97
        return 0;
 
98
}