Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of PicoTCP by
include/PicoCondition.h
- Committer:
- tass
- Date:
- 2013-05-31
- Revision:
- 5:445d2fc04784
- Child:
- 13:c6662adea07d
File content as of revision 5:445d2fc04784:
#ifndef __PICOMUTEX__ #define __PICOMUTEX__ /* * Cross-Threading Mutex Class */ #include "mbed.h" #include "rtos.h" #include "Queue.h" class PicoCondition { private: Queue <int,1> * queue; public: PicoCondition() { queue = new Queue<int,1>(); } ~PicoCondition() { if(queue) { delete queue; queue = NULL; } } bool unlock(uint32_t millisec=0,int * ptr=NULL) { osStatus status = queue->put(ptr, millisec); return (status == osEventMessage || status == osOK); } bool lock(uint32_t millisec=osWaitForever) { osEvent event = queue->get(millisec); return (event.status == osEventMessage || event.status == osOK); } }; #endif