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:
- daniele
- Date:
- 2013-08-03
- Revision:
- 51:18637a3d071f
- Parent:
- 29:1a47b7151851
File content as of revision 51:18637a3d071f:
#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; 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