#ifndef FUTURE_H
#define FUTURE_H

#include <bson.h>

#include "future-value.h"
#include "mongoc-thread-private.h"

{{ header_comment }}

typedef struct
{
   bool             resolved;
   bool             awaited;
   future_value_t   return_value;
   int              argc;
   future_value_t  *argv;
   mongoc_cond_t    cond;
   bson_mutex_t     mutex;
   bson_thread_t    thread;
} future_t;

future_t *future_new (future_value_type_t return_type, int argc);

future_value_t *future_get_param (future_t *future, int i);

void future_start (future_t *future,
                   void *(*start_routine)(void *));

void future_resolve (future_t *future, future_value_t return_value);

bool future_wait (future_t *future);
bool future_wait_max (future_t *future, int64_t timeout_ms);

void future_get_void (future_t *future);

{% for T in type_list %}
{{ T }}
future_get_{{ T }} (future_t *future);
{% endfor %}

void future_destroy (future_t *future);

#endif /* FUTURE_H */

