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
PicoCondition.h
00001 #ifndef __PICOMUTEX__ 00002 #define __PICOMUTEX__ 00003 /* 00004 * Cross-Threading Mutex Class 00005 */ 00006 00007 #include "mbed.h" 00008 #include "rtos.h" 00009 #include "Queue.h" 00010 00011 class PicoCondition 00012 { 00013 private: 00014 Queue <int,1> * queue; 00015 public: 00016 PicoCondition() 00017 { 00018 queue = new Queue<int,1>(); 00019 } 00020 00021 ~PicoCondition() 00022 { 00023 if(queue) 00024 { 00025 delete queue; 00026 queue = NULL; 00027 } 00028 } 00029 00030 bool unlock(uint32_t millisec=0,int * ptr=NULL) 00031 { 00032 osStatus status; 00033 status = queue->put(ptr, millisec); 00034 return (status == osEventMessage || status == osOK); 00035 } 00036 00037 bool lock(uint32_t millisec=osWaitForever) 00038 { 00039 osEvent event = queue->get(millisec); 00040 return (event.status == osEventMessage || event.status == osOK); 00041 } 00042 }; 00043 00044 00045 #endif
Generated on Thu Jul 14 2022 08:24:59 by
1.7.2
