/*
 * zSemaphore.h
 * 
 * The Zen API 
 * Copyright (C) 2009 by LMI Technologies Inc.
 * 
 * Licensed under The MIT License.
 * Redistributions of files must retain the above copyright notice.
 */
#ifndef LMITECH_ZSEMAPHORE_H_INCLUDED
#define LMITECH_ZSEMAPHORE_H_INCLUDED

#include <zApi.h>
#include <zApiBegin.h>

typedef zHandle zSemaphore;      // Represents a semaphore object for thread synchronization.

ZAPI_EXPORT(zStatus) zSemaphore_Construct(zSemaphore* semaphore, z32u initialCount); //
//
//  Description:
//      Constructs a semaphore object.
//  Arguments:
//      semaphore - Destination for the constructed object handle.
//      initialCount - Initial value of the semaphore.

ZAPI_EXPORT(zStatus) zSemaphore_Destroy(zSemaphore semaphore); //
//
//  Description:
//      Destroys the semaphore object.
//  Arguments:
//      semaphore - The semaphore object to be destroyed.

ZAPI_EXPORT(zStatus) zSemaphore_Post(zSemaphore semaphore); //
//
//  Description:
//      Increments the semaphore.
//  Arguments:
//      semaphore - Semaphore object.

ZAPI_EXPORT(zStatus) zSemaphore_Wait(zSemaphore semaphore, z64u timeout); //
//
//  Description:
//      Waits until the semaphore can be decremented or the timeout interval has elapsed.
//  Arguments:
//      sempahore - Semaphore object.
//      timeout - Timeout in microseconds, or zINFINITE to wait indefinitely.
//  Remarks:
//      zERROR_TIMEOUT is returned if the timeout elapses before the semaphore can be decremented. 

#include <zApiEnd.h>

#endif          /* #ifndef LMITECH_ZSEMAPHORE_H_INCLUDED */
