System

From CometPublic

Jump to: navigation, search

Contents

[edit] System APIs

[edit] $System

The classname starts with a $ sign to make sure that end-users cannot directly instantiate it. Instead, there is one global instance of this class named System that users can use to invoke any method. This is used to make sure that the class is a singleton.

  class $System {
     int argc();
     string[] getArgs();
     void sleep(int);
     int getMAXINT();
     float sqrt(float);
     int exec(string);
     int exec(string,string);
     int exec(string,string,string);
     int getCPUTime();
     int getWCTime();
     void forceGC();
     void printStack();
     void backtrace();
     Thread getThread();
     void terminate();
     void terminate(int); // terminates with supplied exit code 
     void suspend();
     void resume(Thread);
     $System::$System();
     void setDeterministic();
     void waitEvents();
     void setAsleep();
     void wakeup();
     boolean asleep();
     void lock();
     void unlock();
  }

[edit] Thread

Comet threads are created with instructions of the form

  thread t {
      <some block of code>
  }

The name t is a local variable bound to an instance of type Thread describing the native thread that executes the block of code.

  class Thread {
     void join();
     void detach();
     void suspend();
     void resume();
  }

[edit] Mutex

This class is obsolete. From now on, we can use the 'synchronized' keyword on an instance or on a class to request that the object behaves as a monitor. The synchronized keyword can also be used on a block for a finer level of control (mutexes are used internally of course).

  class Mutex {
     Mutex::Mutex();
     void lock();
     void unlock();
  }

[edit] RMutex

This class is obsolete and used to represent a recursive mutex. From now on, we can use the 'synchronized' keyword on an instance or on a class to request that the object behaves as a monitor. The synchronized keyword can also be used on a block for a finer level of control (mutexes are used internally of course). Note that the synchronized construction always uses recursive mutexes.


  class RMutex {
     RMutex::RMutex();
     void lock();
     void unlock();
  }

[edit] BCondition

  class BCondition {
     BCondition::BCondition();
     void wait(Mutex);
     void notice();
     void broadcast();
  }
  

[edit] Barrier

  class Barrier {
     Barrier::Barrier(int);
     void enter();
  }
  

[edit] ZeroWait

  class ZeroWait {
     ZeroWait::ZeroWait();
     void incr();
     void decr();
     void wait();
     void incr(int);
  }


[edit] Input / Output

[edit] $stdout

Supported interfaces: Interfaces#ostream

This class has one instance named cout.

  class $stdout implements ostream {
     $stdout::$stdout();
     void lock();
     void unlock();
     void setCompactStyle();
     void setNamingStyle();
     void setLineStyle();
     void setAddressStyle();
     void setDebugStyle();
  }
  

[edit] ofstream

Supported interfaces: Interfaces#ostream

  class ofstream implements ostream {
     ofstream::ofstream(string);
     void setCompactStyle();
     void setNamingStyle();
     void setLineStyle();
     void setAddressStyle();
     void setDebugStyle();
     void lock();
     void unlock();
  }
  

[edit] istream

  class istream {
     int getInt();
     string getString();
     float getFloat();
  }
  

[edit] ifstream

Super class: #istream

  class ifstream extends istream {
     int getInt();
     string getString();
     float getFloat();
     string getLine();
     boolean good();
     ifstream::ifstream(string);
  }
  

[edit] $stdin

Super class: #istream

This class has one global instance named cin

  class $stdin extends istream {
     int getInt();
     string getString();
     float getFloat();
     $stdin::$stdin();
  }
       

[edit] iomanip

  class iomanip {
     void output();
  }
  

[edit] Endl

Super class: #iomanip

This class has one global instance named endl

  class Endl extends iomanip {
     void output();
  }
  

[edit] Flush

Super class: #iomanip

This class has one global instance named flush

  class Flush extends iomanip {
     void output();
  }
  

[edit] Setw

Super class: #iomanip

  class Setw extends iomanip {
     void output();
     Setw::Setw(int);
  }
  

[edit] SetPrecision

Super class: #iomanip

  class SetPrecision extends iomanip {
     void output();
     SetPrecision::SetPrecision(int);
  }
  

[edit] SetFill

Super class: #iomanip

  class SetFill extends iomanip {
     void output();
     SetFill::SetFill(string);
  }