COSA
An Object-Oriented Platform for Arduino Programming
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
Semaphore.cpp
Go to the documentation of this file.
1
21
#include "
Semaphore.hh
"
22
#include "
Thread.hh
"
23
24
using namespace
Nucleo
;
25
26
void
27
Semaphore::wait
(uint8_t count)
28
{
29
uint8_t key =
lock
();
30
while
(count > m_count) {
31
unlock
(key);
32
Thread::s_running
->
enqueue
(&m_queue);
33
key =
lock
();
34
}
35
m_count -= count;
36
unlock
(key);
37
}
38
39
void
40
Semaphore::signal
(uint8_t count,
bool
flag)
41
{
42
synchronized
{
43
m_count += count;
44
}
45
Thread::s_running
->
dequeue
(&m_queue, flag);
46
}
Nucleo
Definition:
Actor.hh:26
Nucleo::Semaphore::wait
void wait(uint8_t count=1)
Definition:
Semaphore.cpp:27
Nucleo::Thread::dequeue
void dequeue(Head *queue, bool flag=true)
Definition:
Thread.cpp:107
Semaphore.hh
Nucleo::Semaphore::signal
void signal(uint8_t count=1, bool flag=true)
Definition:
Semaphore.cpp:40
lock
uint8_t lock()
Definition:
Types.h:319
Nucleo::Thread::enqueue
void enqueue(Head *queue, Thread *thread=NULL)
Definition:
Thread.cpp:98
Thread.hh
unlock
void unlock(uint8_t key)
Definition:
Types.h:331
Nucleo::Thread::s_running
static Thread * s_running
Definition:
Thread.hh:124
libraries
Nucleo
Semaphore.cpp
Generated on Thu Aug 31 2017 17:02:03 for COSA by
1.8.11