#ifndef SWIFT_THREAD_BARRIER_H
#define SWIFT_THREAD_BARRIER_H

#include <swift/atomic.h>
#include <swift/stdlib.h>
#include <swift/time.h>

#include <swift/thread/api.h>

typedef struct swift_barrier_t swift_barrier_t;

struct swift_barrier_t {
	struct swift_ref_t ref;
	void *data;
	bool on_heap;
};

SWIFT_THREAD_API bool swift_init_barrier(swift_barrier_t *barrier,
	unsigned int size);
SWIFT_THREAD_API void swift_term_barrier(swift_barrier_t *barrier);
SWIFT_THREAD_API swift_barrier_t *swift_new_barrier(unsigned int size);
SWIFT_THREAD_API void swift_del_barrier(swift_barrier_t *barrier);
SWIFT_THREAD_API swift_barrier_t *swift_copy_barrier(swift_barrier_t *barrier);
SWIFT_THREAD_API bool swift_barrier_wait(swift_barrier_t *barrier);

#endif /* SWIFT_THREAD_BARRIER_H */
