Ethernetwebsoc

Dependencies:   C12832_lcd LM75B WebSocketClient mbed-rtos mbed Socket lwip-eth lwip-sys lwip

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Semaphore.h Source File

Semaphore.h

00001 /* Copyright (c) 2012 mbed.org */
00002 #ifndef SEMAPHORE_H
00003 #define SEMAPHORE_H 
00004 
00005 #include <stdint.h>
00006 #include "cmsis_os.h"
00007 
00008 namespace rtos {
00009 
00010 /*! The Semaphore class is used to manage and protect access to a set of shared resources. */
00011 class Semaphore  {
00012 public:
00013     /*! Create and Initialize a Semaphore object used for managing resources. 
00014       \param number of available resources; maximum index value is (count-1).
00015     */
00016     Semaphore (int32_t count);
00017     
00018     /*! Wait until a Semaphore resource becomes available. 
00019       \param   millisec  timeout value or 0 in case of no time-out. (default: osWaitForever).
00020       \return  number of available tokens, or -1 in case of incorrect parameters
00021     */
00022     int32_t wait (uint32_t millisec=osWaitForever);
00023     
00024     /*! Release a Semaphore resource that was obtain with Semaphore::wait.
00025       \return  status code that indicates the execution status of the function. 
00026     */
00027     osStatus release (void);
00028     
00029     ~Semaphore ();
00030 
00031 private:
00032     osSemaphoreId _osSemaphoreId;
00033     osSemaphoreDef_t _osSemaphoreDef;
00034 #ifdef CMSIS_OS_RTX
00035     uint32_t _semaphore_data[2];
00036 #endif
00037 };
00038 
00039 }
00040 #endif