| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
#pragma once |
| 23 |
|
| 24 |
#if !defined (DEX_INSIDE) && !defined (DEX_COMPILATION) |
| 25 |
# error "Only <libdex.h> can be included directly." |
| 26 |
#endif |
| 27 |
|
| 28 |
#include "dex-scheduler.h" |
| 29 |
#include "dex-thread-pool.h" |
| 30 |
#include "dex-version-macros.h" |
| 31 |
|
| 32 |
G_BEGIN_DECLS |
| 33 |
|
| 34 |
#define DEX_TYPE_LIMITER (dex_limiter_get_type()) |
| 35 |
#define DEX_LIMITER(obj) (G_TYPE_CHECK_INSTANCE_CAST(obj, DEX_TYPE_LIMITER, DexLimiter)) |
| 36 |
#define DEX_IS_LIMITER(obj) (G_TYPE_CHECK_INSTANCE_TYPE(obj, DEX_TYPE_LIMITER)) |
| 37 |
|
| 38 |
typedef struct _DexLimiter DexLimiter; |
| 39 |
|
| 40 |
DEX_AVAILABLE_IN_1_2 |
| 41 |
GType dex_limiter_get_type (void); |
| 42 |
DEX_AVAILABLE_IN_1_2 |
| 43 |
DexLimiter *dex_limiter_new (guint max_concurrency); |
| 44 |
DEX_AVAILABLE_IN_1_2 |
| 45 |
DexFuture *dex_limiter_close_after_drain (DexLimiter *limiter) G_GNUC_WARN_UNUSED_RESULT; |
| 46 |
DEX_AVAILABLE_IN_1_2 |
| 47 |
guint dex_limiter_get_max_concurrency (DexLimiter *limiter); |
| 48 |
DEX_AVAILABLE_IN_1_2 |
| 49 |
DexFuture *dex_limiter_acquire (DexLimiter *limiter) G_GNUC_WARN_UNUSED_RESULT; |
| 50 |
DEX_AVAILABLE_IN_1_2 |
| 51 |
void dex_limiter_release (DexLimiter *limiter); |
| 52 |
DEX_AVAILABLE_IN_1_2 |
| 53 |
DexFuture *dex_limiter_run (DexLimiter *limiter, |
| 54 |
DexScheduler *scheduler, |
| 55 |
gsize stack_size, |
| 56 |
DexFiberFunc func, |
| 57 |
gpointer func_data, |
| 58 |
GDestroyNotify func_data_destroy) G_GNUC_WARN_UNUSED_RESULT; |
| 59 |
DEX_AVAILABLE_IN_1_2 |
| 60 |
DexFuture *dex_limiter_run_coroutine (DexLimiter *limiter, |
| 61 |
DexScheduler *scheduler, |
| 62 |
DexCoroutineFunc func, |
| 63 |
gpointer user_data, |
| 64 |
GDestroyNotify user_data_destroy) G_GNUC_WARN_UNUSED_RESULT; |
| 65 |
DEX_AVAILABLE_IN_1_2 |
| 66 |
DexFuture *dex_limiter_run_on_pool (DexLimiter *limiter, |
| 67 |
DexThreadPool *pool, |
| 68 |
DexThreadFunc thread_func, |
| 69 |
gpointer user_data, |
| 70 |
GDestroyNotify user_data_destroy) G_GNUC_WARN_UNUSED_RESULT; |
| 71 |
DEX_AVAILABLE_IN_1_2 |
| 72 |
void dex_limiter_close (DexLimiter *limiter); |
| 73 |
|
| 74 |
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DexLimiter, dex_unref) |
| 75 |
|
| 76 |
G_END_DECLS |