blob: 576c20e09aeea5cb8e0426ecfaed029e6e0c18ca [file] [log] [blame]
ctiller3bf466f2014-12-19 16:21:57 -08001/*
2 *
Craig Tiller6169d5f2016-03-31 07:46:18 -07003 * Copyright 2015, Google Inc.
ctiller3bf466f2014-12-19 16:21:57 -08004 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above
13 * copyright notice, this list of conditions and the following disclaimer
14 * in the documentation and/or other materials provided with the
15 * distribution.
16 * * Neither the name of Google Inc. nor the names of its
17 * contributors may be used to endorse or promote products derived from
18 * this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
33
Craig Tiller9a4dddd2016-03-25 17:08:13 -070034#ifndef GRPC_CORE_LIB_IOMGR_TIMER_HEAP_H
35#define GRPC_CORE_LIB_IOMGR_TIMER_HEAP_H
ctiller3bf466f2014-12-19 16:21:57 -080036
Craig Tiller9533d042016-03-25 17:11:06 -070037#include "src/core/lib/iomgr/timer.h"
ctiller3bf466f2014-12-19 16:21:57 -080038
39typedef struct {
David Garcia Quintasf747bbc2015-10-04 23:09:47 -070040 grpc_timer **timers;
Craig Tiller7536af02015-12-22 13:49:30 -080041 uint32_t timer_count;
42 uint32_t timer_capacity;
David Garcia Quintasf747bbc2015-10-04 23:09:47 -070043} grpc_timer_heap;
ctiller3bf466f2014-12-19 16:21:57 -080044
David Garcia Quintasf747bbc2015-10-04 23:09:47 -070045/* return 1 if the new timer is the first timer in the heap */
46int grpc_timer_heap_add(grpc_timer_heap *heap, grpc_timer *timer);
ctiller3bf466f2014-12-19 16:21:57 -080047
David Garcia Quintasf747bbc2015-10-04 23:09:47 -070048void grpc_timer_heap_init(grpc_timer_heap *heap);
49void grpc_timer_heap_destroy(grpc_timer_heap *heap);
ctiller3bf466f2014-12-19 16:21:57 -080050
David Garcia Quintasf747bbc2015-10-04 23:09:47 -070051void grpc_timer_heap_remove(grpc_timer_heap *heap, grpc_timer *timer);
52grpc_timer *grpc_timer_heap_top(grpc_timer_heap *heap);
53void grpc_timer_heap_pop(grpc_timer_heap *heap);
ctiller3bf466f2014-12-19 16:21:57 -080054
David Garcia Quintasf747bbc2015-10-04 23:09:47 -070055int grpc_timer_heap_is_empty(grpc_timer_heap *heap);
ctiller3bf466f2014-12-19 16:21:57 -080056
Craig Tiller9a4dddd2016-03-25 17:08:13 -070057#endif /* GRPC_CORE_LIB_IOMGR_TIMER_HEAP_H */