« Home » « Learn » « Download » « Github »

logo

Cello High Level C

Methods

lock

void lock(var self);

Wait until a lock can be aquired on object self.

trylock

bool trylock(var self);

Try to acquire a lock on object self. Returns true on success and false if the resource is busy.

unlock

void unlock(var self);

Release lock on object self.

Examples

Usage

var x = new(Mutex);
lock(x);   /* Lock Mutex */ 
print("Inside Mutex!\n");
unlock(x); /* Unlock Mutex */

Lock


Exclusive Resource

The Lock class can be implemented by types to limit the access to them. For example this class is implemented by the Mutex type to provide mutual exclusion across Threads.

Definition

struct Lock {
  void (*lock)(var);
  void (*unlock)(var);
  bool (*trylock)(var);
};

Implementers

  • Mutex |     Mutual Exclusion Lock

Back