LAN(Wi-Fi) air controller through the Internet. Also you can use TANK. See:http://wizard.nestegg.jp/lanir.html

Dependencies:   EthernetNetIf mbed HTTPServer

Semaphore.h

Committer:
halfpitch
Date:
2011-08-01
Revision:
0:6f9648f5eaab

File content as of revision 0:6f9648f5eaab:

//  Copyright (C) 2010 Robert M. Bouwens

#ifndef _SEMAPHORE_H_
#define _SEMAPHORE_H_

/*
 * http://mbed.org/forum/mbed/topic/181/#comment-799
 */

class Semaphore {
public:
    Semaphore(): s(SemFree) {};

    bool try_enter() {
        int oldval = __ldrex(&s);
        if (oldval == SemTaken) {
            __clrex();
            return false;
        }
        s = SemTaken;
        __clrex();
        return SemTaken == s;
    };

    void release() {
        s = SemFree;
    };

private:
    enum { SemFree = 1, SemTaken = 2 };
    volatile int s;
};

#endif