Ceylan::System Namespace Reference

General system calls and properties. More...


Namespaces

namespace  Signal

Classes

class  AnonymousInputOutputStream
 Abstract anonymous input/output stream class used in IPC. More...
class  AnonymousInputStream
 Abstract anonymous input stream class used in IPC. More...
class  Console
 Provides a console abstraction for basic output of text in a terminal. More...
class  DirectoryDelegatingException
 Thrown when file operations failed because of underlying filesystem manager: the corresponding backend could not be retrieved as expected. More...
class  Directory
 Abstract directory mother class, so that programs can always manipulate Ceylan::Directory instances, whereas per-platform specialized classes are actually used by the system. More...
class  FIFO
 Interrupt-based FIFO (First In, First Out) class for command-based Inter-Process Communication (IPC). More...
class  FileReadLockingFailed
class  FileReadUnlockingFailed
class  FileWriteLockingFailed
class  FileWriteUnlockingFailed
class  FileDelegatingException
 Thrown when file operations failed because of underlying filesystem manager: the corresponding backend could not be retrieved as expected. More...
class  File
 Abstract file mother class, so that programs can always manipulate Ceylan::File instances, whereas per-platform specialized classes are actually used by the system. More...
class  FileLocatorException
 Exception raised when file locator could not fulfill a request. More...
class  FileLocator
 File locators allow to find files in a set of directories, as Unix PATH variables do. More...
class  FileManagementException
 Mother class of all file-related exceptions, including filesystems, files and directories. More...
class  FileSystemException
 Thrown when filesystem operations failed. More...
class  ConversionFailed
 Thrown when the conversion of a filesystem object failed. More...
class  DuplicateFailed
 Thrown when the duplication of a filesystem object failed. More...
class  FileException
 Thrown when file operations failed. More...
class  FileCreationFailed
 Raised at first by FileSystemManager and file-specific. More...
class  FileOpeningFailed
 Raised at first by FileSystemManager and file-specific. More...
class  FileAlreadyOpened
 Raised at first by FileSystemManager and file-specific. More...
class  FileLookupFailed
 Raised at first by FileSystemManager and file-specific. More...
class  FileRemoveFailed
 Raised at first by FileSystemManager and file-specific. More...
class  FileMoveFailed
 Raised at first by FileSystemManager and file-specific. More...
class  FileCopyFailed
 Raised at first by FileSystemManager and file-specific. More...
class  FileSizeRequestFailed
 Raised at first by FileSystemManager and file-specific. More...
class  FileLastChangeTimeRequestFailed
 Raised at first by FileSystemManager and file-specific. More...
class  FileTouchFailed
 Raised at first by FileSystemManager and file-specific. More...
class  FileDiffFailed
 Raised at first by FileSystemManager and file-specific. More...
class  DirectoryException
 Thrown when directory operations failed. More...
class  DirectoryCreationFailed
 Raised at first by FileSystemManager and directory-specific. More...
class  DirectoryOpeningFailed
 Raised at first by FileSystemManager and directory-specific. More...
class  DirectoryLookupFailed
 Raised at first by FileSystemManager and directory-specific. More...
class  DirectoryRemoveFailed
 Raised at first by FileSystemManager and directory-specific. More...
class  DirectoryMoveFailed
 Raised at first by FileSystemManager and directory-specific. More...
class  DirectoryCopyFailed
 Raised at first by FileSystemManager and directory-specific. More...
class  DirectoryLastChangeTimeRequestFailed
 Raised at first by FileSystemManager and directory-specific. More...
class  DirectoryGetCurrentFailed
 Raised at first by FileSystemManager and directory-specific. More...
class  DirectoryChangeFailed
 Raised at first by FileSystemManager and directory-specific. More...
class  FileSystemManagerException
 Thrown when filesystem manager operations failed. More...
class  EntryLookupFailed
class  SymlinkFailed
class  GetChangeTimeFailed
class  FileSystemManagerDelegatingException
class  FileSystemManager
 Interface (abstract class) that allows to manage a specific filesystem. More...
class  InputOutputStream
 Abstract input/output stream class used in IPC. More...
class  InputStream
 Abstract input stream class used in IPC. More...
class  LibfatDirectory
 Encapsulates libfat directories, as provided by usual operating systems. More...
class  LibfatFileException
 Mother class for all exceptions related to libfat files. More...
class  LibfatFile
 Encapsulates libfat-based files, as provided by the libfat DS library. More...
class  LibfatFileSystemManagerException
class  LibfatFileSystemManager
 Allows to manage a libfat-based filesystem directly, with no OS support, on platforms that support it, i.e. More...
class  MemoryStream
 Makes a buffer in memory behaving like an InputOutputStream. More...
class  Mutex
 Simple mutual exclusion device. More...
class  OutputStream
 Abstract output stream class used in IPC. More...
class  Pipe
 Pipe class for Inter-Process Communication (IPC). More...
class  ProcessException
 Exception class for process concerns. More...
class  Process
class  RunnableException
 Exception class for runnable concerns. More...
class  Runnable
 Basic runnable interface. More...
class  StandardDirectory
 Encapsulates standard directories, as provided by usual operating systems. More...
class  StandardFileException
 Mother class for all exceptions related to standard files. More...
class  StandardFile
 Encapsulates standard files, as provided by usual operating systems, i.e. More...
class  StandardFileSystemManagerException
class  StandardFileSystemManager
 Allows to interact with the filesystems supported by any underlying operation system. More...
class  Stream
 Abstract stream class used in IPC. More...
class  Synchronized
 Template defining generically objects (notably numerical datatypes) protected by a mutex. More...
class  Synchronized< bool >
 Partial specialization of the Synchonized template for bool. More...
class  SystemException
 Exception raised when system operation fails. More...
class  IOException
 Exception raised when basic input/output operation fails. More...
class  Thread
 Basic abstract class for threaded objects. More...

Typedefs

typedef Ceylan::Uint32 FIFOElement
 The atomic data that can be sent through the FIFO.
typedef Ceylan::Uint16 OpeningFlag
 File opening openFlags, they can be OR'ed.
typedef Ceylan::Uint16 PermissionFlag
 File creation abstract permissions, to be used in case a new file is created.
typedef Ceylan::Uint32 Pid
 Describes a Process Identifier (PID).
typedef void(* Callback )(void *data)
 Signature of an classical callback function.
typedef int StreamID
 A stream's unique ID.
typedef size_t Size
 Unsigned size, in bytes, for example for file operations.
typedef long Position
 Unsigned position, in bytes, for example for file operations.
typedef ssize_t SignedSize
 Signed size, in bytes, for example for file operations.
typedef Uint32 Second
 Records seconds, even for long periods of time (more than a century).
typedef Uint32 Millisecond
 Records milliseconds, which last 10^3 second.
typedef Uint32 Microsecond
 Records microseconds, which last 10^6 second.
typedef Uint32 Nanosecond
 Records nanoseconds, which last 10^9 second.
typedef int FileDescriptor
 UNIX File descriptor type, they have to be transformed into the StreamID datatype to comply with the Stream interface.
typedef int ErrorCode
 Error number as defined by errno.
typedef int InterruptMask
 Masks describing which interrupts are enabled.
typedef void(* IRQHandler )(void)
 Signature of an interrupt handler.
typedef Ceylan::Uint32 ThreadCount
 Data type to store numbers of threads.

Enumerations

enum  BatteryStatus { WellCharged, AlmostEmpty, BatteryStatusUnknown }
 Describes the status of the battery (if any). More...
enum  DSType { DSFat, DSLite, DSTypeUnknown }
 Describes the type of a Nintendo DS. More...

Functions

CEYLAN_DLL bool isEnvironmentVariableSet (const std::string &variableName)
 Returns whether the specified environment variable is set.
CEYLAN_DLL const std::string getEnvironmentVariable (const std::string &variableName)
 Returns the value of specified environment variable.
CEYLAN_DLL void setEnvironmentVariable (const std::string &variableName, const std::string &variableValue)
 Sets specified environment variable to the specified value.
CEYLAN_DLL void unsetEnvironmentVariable (const std::string &variableName)
 Unsets specified environment variable.
CEYLAN_DLL ErrorCode getError ()
 Returns the error ID (errno).
CEYLAN_DLL std::string explainError (ErrorCode errorID)
 Returns the diagnosis string corresponding to errorID (errno).
CEYLAN_DLL std::string explainError ()
 Returns the diagnosis string corresponding to current error ID (errno).
CEYLAN_DLL std::string getShellName ()
 Returns the name of the default shell, if found, otherwise returns an empty string.
CEYLAN_DLL void InitializeInterrupts (bool force=false)
 On platforms requiring it (ex: the Nintendo DS), initializes the interrupt system by using a default handler.
CEYLAN_DLL InterruptMask SetEnabledInterrupts (InterruptMask newMask=AllInterruptsDisabled)
 On platforms supporting it (ex: the Nintendo DS on the ARM9), sets the current set of interrupts enabled.
CEYLAN_DLL void InitializeIPC ()
 On platforms requiring it (ex: the Nintendo DS), initializes the IPC system (Inter-Process Communication), by setting up the FIFO infrastructure (creation and activation).
template<typename T >
T * ConvertToNonCacheable (T *sourceAddress)
 Converts specified address, expected to be in main RAM, into a mirrored address in the non-cacheable RAM mirror.
CEYLAN_DLL Ceylan::ByteCacheProtectedNew (Size numberOfBytes)
 Reserves the specified size of memory so that it is compliant with the Nintendo DS ARM9 data cache, i.e.
CEYLAN_DLL void CacheProtectedDelete (Ceylan::Byte *cacheProtectedBuffer)
 Deallocates the specified cache-protected buffer.
CEYLAN_DLL bool HasAvailableData (FileDescriptor fd)
 Tells whether there is data available on specified file descriptor.
CEYLAN_DLL Size FDRead (FileDescriptor fd, Ceylan::Byte *dataBuffer, Size toReadBytesNumber)
 Reads from fd stream to dataBuffer toReadBytesNumber bytes.
CEYLAN_DLL Size FDWrite (FileDescriptor fd, const Ceylan::Byte *dataBuffer, Size toWriteBytesNumber)
 Writes to fd stream from dataBuffer toWriteBytesNumber bytes.
CEYLAN_DLL Second getTime ()
 Returns the current time since the Epoch (00:00:00 UTC, January 1, 1970), measured in seconds.
CEYLAN_DLL std::string timeToString (const time_t &t)
 Converts the time moment into a human readable string.
CEYLAN_DLL std::string durationToString (Second startingSecond, Microsecond startingMicrosecond, Second stoppingSecond, Microsecond stoppingMicrosecond)
CEYLAN_DLL Microsecond getDurationBetween (Second startingSecond, Microsecond startingMicrosecond, Second stoppingSecond, Microsecond stoppingMicrosecond)
 Returns the duration, in microseconds, between the two specified times, i.e.
CEYLAN_DLL void getPreciseTime (Second &seconds, Microsecond &microsec)
 Returns the time since the Epoch (00:00:00 UTC, January 1, 1970), with up to a one microsecond accuracy, expressed as a pair containing the number of seconds and the number of microseconds elapsed.
CEYLAN_DLL Microsecond getAccuracyOfPreciseTime (Microsecond *minGap=0, Microsecond *maxGap=0)
 Returns the mean runtime-computed actual accuracy if the precise time measurement, expressed in microseconds.
CEYLAN_DLL Microsecond getPreciseTimeCallDuration ()
 Returns the mean duration of a call to getPreciseTime.
CEYLAN_DLL void sleepForSeconds (Second secondCount)
 Sleeps for the specified number of seconds.
CEYLAN_DLL bool areSubSecondSleepsAvailable ()
 Tells whether sub-second sleeps can be performed.
CEYLAN_DLL void atomicSleep ()
 Makes the process sleep for a quite small duration, which is probably the smallest possible duration on the system, scheduler-wise, i.e.
CEYLAN_DLL void basicSleep (Second secondCount, Nanosecond nanoCount)
 Makes the process basically sleep for (at least) specified duration.
CEYLAN_DLL void basicSleep (Microsecond micros)
 Makes the process basically sleep for (at least) specified duration.
CEYLAN_DLL bool smartSleep (Second secondCount, Microsecond microCount)
 Makes the process smartly sleep for the specified duration.
CEYLAN_DLL bool smartSleepUntil (Second secondCount, Microsecond microCount)
 Makes the process smartly sleep until the specified time arrives.
CEYLAN_DLL Microsecond getActualDurationForSleep (Microsecond requestedMicroseconds, Second requestedSeconds=0)
 Sleeps, and returns the actual sleeping time corresponding to the requested sleeping time, expressed in seconds and microseconds.
CEYLAN_DLL Microsecond getSchedulingGranularity ()
 Returns the run-time computed scheduling granularity of the time slice enforced by the operating system.
CEYLAN_DLL bool setLegacyStreamSynchronization (bool synchronized)
 Sets whether the C++ standard streams (cin, cout, cerr, clog, and their wide-character counterparts) should be synchronized with their C-stream counterparts (this is the default situation).
CEYLAN_DLL UnsignedLongInteger getSecondsSinceSystemBoot ()
 Returns the uptime, the number of seconds since the system booted.
CEYLAN_DLL Ceylan::Uint32 getTotalProcessCount ()
 Returns the current number of running processes.
CEYLAN_DLL UnsignedLongInteger getTotalSystemMemorySize ()
 Returns the total size of usable main memory, in bytes.
CEYLAN_DLL UnsignedLongInteger getFreeSystemMemorySize ()
 Returns the size of currently available main memory, in bytes.
CEYLAN_DLL UnsignedLongInteger getUsedSystemMemorySize ()
 Returns the size of main memory being currently used, in bytes.
CEYLAN_DLL UnsignedLongInteger getTotalSwapMemorySize ()
 Returns the total size of swap memory, in bytes.
CEYLAN_DLL UnsignedLongInteger getFreeSwapMemorySize ()
 Returns the size of currently available swap memory, in bytes.
CEYLAN_DLL UnsignedLongInteger getTotalHighMemorySize ()
 Returns the total size of usable high memory, in bytes.
CEYLAN_DLL UnsignedLongInteger getFreeHighMemorySize ()
 Returns the size of currently available high memory, in bytes.
CEYLAN_DLL UnsignedLongInteger getSharedMemorySize ()
 Returns the size of memory currently being shared, in bytes.
CEYLAN_DLL UnsignedLongInteger getBuffersMemorySize ()
 Returns the size of memory currently used by buffers, in bytes.
CEYLAN_DLL std::string GetUserName ()
 Returns the name of the user, as retrieved from the system.
CEYLAN_DLL BatteryStatus GetBatteryStatus ()
 Returns the current battery status.
CEYLAN_DLL DSType GetDSType ()
 Returns the type of the DS running the program.
CEYLAN_DLL bool openGLContextsCanBeLost ()
 Tells whether the OpenGL contexts can be lost (and therefore may have to be reloaded) under certain unexpected circumstances (ex : window resize, going to fullscreen, switching to another application, etc.
CEYLAN_DLL bool openGLContextsLostOnResize ()
 Tells whether the OpenGL contexts are lost (and therefore may have to be reloaded) when the window application is resized (resolution changed).
CEYLAN_DLL bool openGLContextsLostOnApplicationSwitch ()
 Tells whether the OpenGL contexts are lost (and therefore may have to be reloaded) when switching to another application.
CEYLAN_DLL bool openGLContextsLostOnColorDepthChange ()
 Tells whether the OpenGL contexts are lost (and therefore may have to be reloaded) when changing the color depth.

Variables

CEYLAN_DLL const InterruptMask AllInterruptsDisabled = 0
 To specify that all interrupts are to disabled (null value).
CEYLAN_DLL const Second MaximumDurationWithMicrosecondAccuracy = 4100
 The maximum number of seconds for durations to be evaluated with a microsecond accuracy, before an overflow may occur.


Detailed Description

General system calls and properties.

System query primitives.

Manages in a C++ user-friendly fashion basic system services.

Note:
Load reporting could be added in cross-platform meaning can be found.


Typedef Documentation

typedef void(* Ceylan::System::Callback)(void *data)

Signature of an classical callback function.

They can be useful so that functions can change behaviour by calling such generic callbacks. These caller functions do not have to know their callbacks a priori.

The data parameter allows to customize the callback, which will have to cast the given argument to the specific data it is actually looking for.

Even though no exception specification can be specified, the callback should not throw any exception whatsoever.

Definition at line 76 of file CeylanRunnable.h.

Error number as defined by errno.

Definition at line 186 of file CeylanSystem.h.

The atomic data that can be sent through the FIFO.

Definition at line 65 of file CeylanFIFO.h.

UNIX File descriptor type, they have to be transformed into the StreamID datatype to comply with the Stream interface.

Also needed on Windows for socket handles (SOCKET datatype), whose type is UINT_PTR.

Definition at line 179 of file CeylanSystem.h.

Masks describing which interrupts are enabled.

Definition at line 235 of file CeylanSystem.h.

typedef void(* Ceylan::System::IRQHandler)(void)

Signature of an interrupt handler.

Definition at line 245 of file CeylanSystem.h.

Records microseconds, which last 10^6 second.

Definition at line 124 of file CeylanSystem.h.

Records milliseconds, which last 10^3 second.

Definition at line 116 of file CeylanSystem.h.

Records nanoseconds, which last 10^9 second.

Definition at line 132 of file CeylanSystem.h.

File opening openFlags, they can be OR'ed.

At least one of the { Read ; Write } pair must be set.

Definition at line 54 of file CeylanFile.h.

File creation abstract permissions, to be used in case a new file is created.

Permissions can be OR'ed.

Actual permissions can be modified by the umask of the process, according to (actualPermissionFlag & ~umask).

Note:
When the file descriptor and/or the advanced file attribute features are not enabled, the permissions which are not managed are ignored.

Definition at line 82 of file CeylanFile.h.

Describes a Process Identifier (PID).

Definition at line 75 of file CeylanProcess.h.

Unsigned position, in bytes, for example for file operations.

Definition at line 72 of file CeylanSystem.h.

Records seconds, even for long periods of time (more than a century).

Note:
This can be useful to record dates expressed as a number of seconds since the Epoch, 00:00:00 on January 1, 1970, Coordinated Universal Time (UTC).

Definition at line 108 of file CeylanSystem.h.

typedef ssize_t Ceylan::System::SignedSize

Signed size, in bytes, for example for file operations.

Definition at line 93 of file CeylanSystem.h.

typedef size_t Ceylan::System::Size

Unsigned size, in bytes, for example for file operations.

Definition at line 64 of file CeylanSystem.h.

A stream's unique ID.

Note:
A value of -1 denotes an invalid stream ID.

Definition at line 55 of file CeylanStream.h.

Data type to store numbers of threads.

Definition at line 54 of file CeylanThread.h.


Enumeration Type Documentation

Describes the status of the battery (if any).

Enumerator:
WellCharged  Indicates that the charge of a battery is still high.
AlmostEmpty  Indicates that the charge of a battery is getting quite low.
BatteryStatusUnknown  Indicates that the charge of a battery is not known.

Definition at line 233 of file CeylanSystemInformation.h.

Describes the type of a Nintendo DS.

Enumerator:
DSFat  The first DS release.
DSLite  The update of the first DS.
DSTypeUnknown  Indicates that the type of the DS is not known.

Definition at line 270 of file CeylanSystemInformation.h.


Function Documentation

bool Ceylan::System::areSubSecondSleepsAvailable (  ) 

Tells whether sub-second sleeps can be performed.

On some platforms (UNIX) it requires the file descriptor feature to be activated.

Note:
Should be checked before calling notably atomicSleep, basicSleep, smartSleep, smartSleepUntil, getSchedulingGranularity, etc., as otherwise a System exception might be thrown.

Definition at line 1210 of file CeylanSystem.cc.

References generalUtils::false, and generalUtils::true.

Referenced by Ceylan::waitForKey().

void Ceylan::System::atomicSleep (  ) 

Makes the process sleep for a quite small duration, which is probably the smallest possible duration on the system, scheduler-wise, i.e.

exactly one time slice.

This is useful to spare CPU time/battery life by avoiding busy loops, without needing fine-grained timing: it is just a convenient way of adding a delay in a busy loop so that it becomes more resource-friendly, while minimizing the delay.

Note:
The first call to this method may trigger the computing of the scheduling granularity, which takes some time.
Exceptions:
SystemException if the operation failed, included if the necessary file descriptor feature is not available.
See also:
Ceylan::Features::areFileDescriptorsSupported to check it prior to calling this sleep method.
Makes the process sleep for a quite small duration, which is probably the smallest possible duration on the system, scheduler-wise, i.e.

Needs the VBlank IRQ to be enabled.

Definition at line 1349 of file CeylanSystem.cc.

References basicSleep(), getSchedulingGranularity(), and InitializeInterrupts().

Referenced by Ceylan::System::FIFO::activate(), Ceylan::System::FIFO::deactivate(), Ceylan::System::FIFO::FIFO(), Ceylan::System::FIFO::getBatteryStatus(), Ceylan::getChar(), Ceylan::System::FIFO::getDSType(), initCeylanIPC(), initCeylanSound(), Ceylan::System::LibfatFileSystemManager::LibfatFileSystemManager(), smartSleep(), and Ceylan::waitForKey().

void Ceylan::System::basicSleep ( Microsecond  micros  ) 

Makes the process basically sleep for (at least) specified duration.

See also:
basicSleep( Second seconds, Nanosecond nanos )

Definition at line 1399 of file CeylanSystem.cc.

References basicSleep(), and OneMillion.

void Ceylan::System::basicSleep ( Second  secondCount,
Nanosecond  nanoCount 
)

Makes the process basically sleep for (at least) specified duration.

Sleeps are far better than busy waiting (waiting loops) insofar as other processes can be executed during the sleep, and most laptops should consume less power that way.

The problem with basic sleeping is that it depends on the granularity of the scheduling for the underlying operating system. For example, no sleep may be shorter than 10 ms on Linux/i386 (prior to kernel 2.6) and 1 ms on Linux/Alpha.

Parameters:
secondCount the number of seconds to wait
nanoCount the remaining part of the time to wait, expressed as a number of nanoseconds. As full seconds should be taken into account with the parameter second, nanos should be less than one second, i.e. should be in the range 0 to 10E9 - 1.
Exceptions:
SystemException if a non-blocked signal interrupted the sleep, or if the nanos parameter was out of range, or if the necessary file descriptor feature is not available.
See also:
Ceylan::Features::areFileDescriptorsSupported to check it prior to calling this sleep method.

Definition at line 1238 of file CeylanSystem.cc.

References explainError(), InitializeInterrupts(), OneMillion, and Ceylan::toString().

Referenced by atomicSleep(), basicSleep(), getActualDurationForSleep(), Ceylan::System::Thread::Sleep(), sleepForSeconds(), and smartSleep().

void Ceylan::System::CacheProtectedDelete ( Ceylan::Byte cacheProtectedBuffer  ) 

Deallocates the specified cache-protected buffer.

Parameters:
cacheProtectedBuffer a buffer created with CacheProtectedNew.
Exceptions:
SystemException if the operation failed, ex: pointer not registered.

Definition at line 448 of file CeylanSystem.cc.

References AllInterruptsDisabled, generalUtils::false, Ceylan::toString(), and generalUtils::true.

Referenced by Ceylan::System::FIFO::~FIFO().

Ceylan::Byte * Ceylan::System::CacheProtectedNew ( Size  numberOfBytes  ) 

Reserves the specified size of memory so that it is compliant with the Nintendo DS ARM9 data cache, i.e.

the returned buffer spreads over an integer number of cache lines, so that flushing or invalidating these lines will not affect other data.

This function is only useful for the DS ARM9.

Parameters:
numberOfBytes the size of the safe buffer to allocate.
Returns:
a pointer to the allocated safe memory.
Note:
Use the CacheProtectedDelete function to deallocate the returned buffer, as the pointer returned by CacheProtectedNew is in most cases different from the actual allocated one, as we have to ensure it is boundary-aligned, regarding the cache lines.
Exceptions:
SystemException if the operation failed, ex: not enough memory.

Definition at line 354 of file CeylanSystem.cc.

References AllInterruptsDisabled, generalUtils::false, and generalUtils::true.

Referenced by Ceylan::System::FIFO::FIFO().

template<typename T >
T* Ceylan::System::ConvertToNonCacheable ( T *  sourceAddress  )  [inline]

Converts specified address, expected to be in main RAM, into a mirrored address in the non-cacheable RAM mirror.

Note:
Ensure that the specified address in the main RAM, i.e. in the 0x0200:0000 to 0x023FF:FFFF range.

Only useful for the DS ARM9, to ensure its data cache is not used, for example when sharing data with the ARM7, which does not see the ARM9 cache.

Definition at line 316 of file CeylanSystem.h.

string Ceylan::System::durationToString ( Second  startingSecond,
Microsecond  startingMicrosecond,
Second  stoppingSecond,
Microsecond  stoppingMicrosecond 
)

Definition at line 889 of file CeylanSystem.cc.

References OneMillion, and Ceylan::toString().

string Ceylan::System::explainError (  ) 

string Ceylan::System::explainError ( ErrorCode  errorID  ) 

Returns the diagnosis string corresponding to errorID (errno).

Definition at line 199 of file CeylanSystem.cc.

Referenced by Ceylan::Network::AnonymousStreamSocket::AnonymousStreamSocket(), basicSleep(), Ceylan::System::StandardFileSystemManager::changeWorkingDirectory(), Ceylan::System::LibfatFileSystemManager::changeWorkingDirectory(), Ceylan::Network::StreamSocket::createSocket(), Ceylan::System::StandardFileSystemManager::createSymbolicLink(), FDRead(), FDWrite(), getBuffersMemorySize(), Ceylan::System::StandardFileSystemManager::getCurrentWorkingDirectoryPath(), Ceylan::System::StandardDirectory::getEntries(), Ceylan::System::StandardFileSystemManager::getEntryChangeTime(), Ceylan::System::LibfatFileSystemManager::getEntryChangeTime(), getEnvironmentVariable(), Ceylan::System::StandardDirectory::getFiles(), getFreeHighMemorySize(), getFreeSwapMemorySize(), getFreeSystemMemorySize(), Ceylan::System::StandardFile::getLastChangeTime(), Ceylan::System::LibfatFile::getLastChangeTime(), Ceylan::System::StandardFileSystemManager::getLastChangeTimeDirectory(), Ceylan::System::LibfatFileSystemManager::getLastChangeTimeDirectory(), Ceylan::System::StandardFileSystemManager::getLastChangeTimeFile(), Ceylan::System::LibfatFileSystemManager::getLastChangeTimeFile(), getPreciseTime(), getSecondsSinceSystemBoot(), getSharedMemorySize(), Ceylan::System::StandardFileSystemManager::getSize(), Ceylan::System::LibfatFileSystemManager::getSize(), Ceylan::System::StandardDirectory::getSortedEntries(), Ceylan::System::StandardDirectory::getSubdirectories(), getTime(), Ceylan::System::Process::GetTime(), getTotalHighMemorySize(), getTotalProcessCount(), getTotalSwapMemorySize(), getTotalSystemMemorySize(), HasAvailableData(), Ceylan::System::Process::kill(), Ceylan::System::LibfatDirectory::LibfatDirectory(), Ceylan::System::StandardFile::lockForReading(), Ceylan::System::StandardFile::lockForWriting(), Ceylan::System::StandardFileSystemManager::moveDirectory(), Ceylan::System::StandardFileSystemManager::moveFile(), Ceylan::System::LibfatFileSystemManager::moveFile(), Ceylan::System::Pipe::Pipe(), Ceylan::Network::ServerStreamSocket::prepareToAccept(), Ceylan::System::Process::processCreationFailed(), Ceylan::System::Pipe::read(), Ceylan::System::StandardFileSystemManager::removeDirectory(), Ceylan::System::LibfatFileSystemManager::removeDirectory(), Ceylan::System::StandardFileSystemManager::removeFile(), Ceylan::System::LibfatFileSystemManager::removeFile(), Ceylan::System::StandardFile::reopen(), Ceylan::System::LibfatFile::reopen(), Ceylan::System::Process::RunExecutable(), Ceylan::System::StandardFile::seek(), Ceylan::System::InputStream::Select(), Ceylan::Network::ServerStreamSocket::ServerStreamSocket(), Ceylan::Network::StreamSocket::setBlocking(), setEnvironmentVariable(), Ceylan::System::StandardDirectory::StandardDirectory(), Ceylan::System::StandardFile::tell(), Ceylan::System::InputStream::Test(), Ceylan::System::Thread::threadCreationFailed(), Ceylan::Timestamp::Timestamp(), Ceylan::System::StandardFileSystemManager::touch(), Ceylan::System::StandardFile::unlockForReading(), Ceylan::System::StandardFile::unlockForWriting(), Ceylan::Network::Socket::write(), and Ceylan::System::Pipe::write().

Size Ceylan::System::FDRead ( FileDescriptor  fd,
Ceylan::Byte dataBuffer,
Size  toReadBytesNumber 
)

Reads from fd stream to dataBuffer toReadBytesNumber bytes.

Will raise an IOException if read fails.

Returns:
the number of bytes that have actually been read, which is zero or more.
Exceptions:
FeatureNotAvailableException if the file descriptor feature is not available, and IOException is a system error occurred.

Definition at line 564 of file CeylanSystem.cc.

References explainError(), Ceylan::Network::explainSocketError(), getError(), Ceylan::Network::getSocketError(), read(), and Ceylan::toString().

Referenced by Ceylan::System::StandardFile::FromFDtoFD(), Ceylan::System::LibfatFile::FromFDtoFD(), Ceylan::System::StandardFile::read(), Ceylan::System::Pipe::read(), and Ceylan::System::LibfatFile::read().

Size Ceylan::System::FDWrite ( FileDescriptor  fd,
const Ceylan::Byte dataBuffer,
Size  toWriteBytesNumber 
)

Writes to fd stream from dataBuffer toWriteBytesNumber bytes.

Will raise an IOException if write fails.

Returns:
the number of bytes that have actually been read.
Exceptions:
FeatureNotAvailableException if the file descriptor feature is not available, and IOException is a system error occurred.

Definition at line 704 of file CeylanSystem.cc.

References explainError(), Ceylan::Network::explainSocketError(), getError(), Ceylan::Network::getSocketError(), Ceylan::toString(), and write().

Referenced by Ceylan::System::StandardFile::FromFDtoFD(), Ceylan::System::LibfatFile::FromFDtoFD(), Ceylan::System::StandardFile::write(), Ceylan::Network::Socket::write(), Ceylan::System::Pipe::write(), and Ceylan::System::LibfatFile::write().

Microsecond Ceylan::System::getAccuracyOfPreciseTime ( Microsecond *  minGap = 0,
Microsecond *  maxGap = 0 
)

Returns the mean runtime-computed actual accuracy if the precise time measurement, expressed in microseconds.

Result is of course one microsecond or more.

The accuracy is measured thanks to two successive calls to getPreciseTime. As most systems are running at 1 GHz or more, they should be able to execute about one instruction per nanosecond, or about 1000 instructions per microsecond. Assuming the instructions involved by the call to getPreciseTime are negligible compared to 1000 instructions, the result should be at least roughly accurate at the millisecond scale.

See also:
getPreciseTime
Parameters:
minGap updates, if non-null, the pointed variable with the smallest measured duration. Should be the actual granularity of the underlying clock.
maxGap updates, if non-null, the pointed variable with the maximal measured duration.
Exceptions:
SystemException should a problem occur.
Note:
A typical value for accuracy on a Linux 2.4 kernel is exactly one microsecond, which is the best possible for this method, which returns an integer number of microseconds. Such a precise accuracy should be overkill for most applications. However, on 2.6 kernels, accuracy is found to be about 3 microseconds.

Definition at line 1027 of file CeylanSystem.cc.

References Ceylan::Log::LogPlug::debug(), getDurationBetween(), getPreciseTime(), and Ceylan::toString().

Microsecond Ceylan::System::getActualDurationForSleep ( Microsecond  requestedMicroseconds,
Second  requestedSeconds = 0 
)

Sleeps, and returns the actual sleeping time corresponding to the requested sleeping time, expressed in seconds and microseconds.

Parameters:
requestedMicroseconds the time to sleep, expressed in microseconds, in the [0, 1 000 000 [ range.
requestedSeconds the full seconds to be waited, not more than an hour to avoid overflow of returned value.
Returns:
the actual slept duration, expressed in microseconds
Exceptions:
SystemException if waiting or measuring time went wrong.

Definition at line 1762 of file CeylanSystem.cc.

References basicSleep(), getDurationBetween(), and getPreciseTime().

Referenced by getSchedulingGranularity().

BatteryStatus Ceylan::System::GetBatteryStatus (  ) 

Returns the current battery status.

On the DS ARM9, the IPC system, namely the singleton FIFO, is expected to be already available (created and activated).

Exceptions:
SystemException if the operation failed.
Note:
On the DS ARM9, it is a synchronous operation: the ARM9 is blocked (polling) until the ARM7 answers.

Definition at line 622 of file CeylanSystemInformation.cc.

References Ceylan::System::FIFO::GetActivatedFIFO(), Ceylan::System::FIFO::getBatteryStatus(), and Ceylan::System::FIFO::sendBatteryStatusRequest().

UnsignedLongInteger Ceylan::System::getBuffersMemorySize (  ) 

Returns the size of memory currently used by buffers, in bytes.

Exceptions:
SystemException on error, or if not implemented for this platform.

Definition at line 530 of file CeylanSystemInformation.cc.

References explainError().

DSType Ceylan::System::GetDSType (  ) 

Returns the type of the DS running the program.

Exceptions:
SystemException if the operation failed.
Note:
On the DS ARM9, it is a synchronous operation: the ARM9 is blocked (polling) until the ARM7 answers.

Definition at line 657 of file CeylanSystemInformation.cc.

References Ceylan::System::FIFO::GetActivatedFIFO(), Ceylan::System::FIFO::getDSType(), and Ceylan::System::FIFO::sendDSTypeRequest().

Microsecond Ceylan::System::getDurationBetween ( Second  startingSecond,
Microsecond  startingMicrosecond,
Second  stoppingSecond,
Microsecond  stoppingMicrosecond 
)

Returns the duration, in microseconds, between the two specified times, i.e.

duration = (stopping time) - (starting time).

Note:
The duration shall not exceed the capacity of the Microsecond storage type, i.e. about 4 200 seconds, a little more than one hour.
Exceptions:
SystemException if the duration is strictly negative, or if duration is above MaximumDurationWithMicrosecondAccuracy, to prevent overflow.
See also:
MaximumDurationWithMicrosecondAccuracy

Definition at line 936 of file CeylanSystem.cc.

References MaximumDurationWithMicrosecondAccuracy, OneMillion, and Ceylan::toString().

Referenced by getAccuracyOfPreciseTime(), getActualDurationForSleep(), and getPreciseTimeCallDuration().

const string Ceylan::System::getEnvironmentVariable ( const std::string &  variableName  ) 

Returns the value of specified environment variable.

If the variable was not set, returns an empty string.

Exceptions:
UtilsException if this operation is not supported or failed.

Definition at line 55 of file CeylanEnvironmentVariables.cc.

References explainError().

Referenced by Ceylan::System::FileLocator::addPathsFromEnvironmentVariable(), getShellName(), and isEnvironmentVariableSet().

ErrorCode Ceylan::System::getError (  ) 

UnsignedLongInteger Ceylan::System::getFreeHighMemorySize (  ) 

Returns the size of currently available high memory, in bytes.

Exceptions:
SystemException on error, or if not implemented for this platform.

Definition at line 439 of file CeylanSystemInformation.cc.

References explainError().

UnsignedLongInteger Ceylan::System::getFreeSwapMemorySize (  ) 

Returns the size of currently available swap memory, in bytes.

Exceptions:
SystemException on error, or if not implemented for this platform.

Definition at line 349 of file CeylanSystemInformation.cc.

References explainError().

UnsignedLongInteger Ceylan::System::getFreeSystemMemorySize (  ) 

Returns the size of currently available main memory, in bytes.

Exceptions:
SystemException on error, or if not implemented for this platform.
See also:
getUsedSystemMemorySize

Definition at line 224 of file CeylanSystemInformation.cc.

References explainError().

void Ceylan::System::getPreciseTime ( Second &  seconds,
Microsecond &  microsec 
)

Returns the time since the Epoch (00:00:00 UTC, January 1, 1970), with up to a one microsecond accuracy, expressed as a pair containing the number of seconds and the number of microseconds elapsed.

On some platforms (Windows XP), accuracy is worse than 1 millisecond.

Parameters:
seconds the variable which will be updated with the number of seconds elapsed.
microsec the variable which will be updated with the number of microseconds elapsed.
Note:
Keep in mind that a microsecond lasts for 10^-6 second.

The returned number of seconds should be roughly equal to: 35 years * 365 days * 24 hours * 3600 seconds = 1 103 760 000 which does not risk overflow when stored in Uint32, whose maximum value is 4 294 967 295. For Pentiums, the rdtsc code fragment is accurate to one clock cycle.

Expect this call to last for about 3 microseconds on 2.6 Linux kernels.

Exceptions:
SystemException should a problem occur.

Definition at line 984 of file CeylanSystem.cc.

References explainError().

Referenced by Ceylan::Maths::Random::WhiteNoiseGenerator::generateSeedFromCurrentTime(), getAccuracyOfPreciseTime(), getActualDurationForSleep(), getPreciseTimeCallDuration(), smartSleep(), and smartSleepUntil().

Microsecond Ceylan::System::getPreciseTimeCallDuration (  ) 

Returns the mean duration of a call to getPreciseTime.

Note:
The computation is done one time for all. The first call may last up to 3 milliseconds. Next calls to this method will return almost immediatly this precomputed value.
Returns:
the mean duration of a call to getPreciseTime

Definition at line 1124 of file CeylanSystem.cc.

References getDurationBetween(), and getPreciseTime().

Referenced by smartSleep().

Microsecond Ceylan::System::getSchedulingGranularity (  ) 

Returns the run-time computed scheduling granularity of the time slice enforced by the operating system.

Sleeping for smaller durations will in general result in sleeping the duration corresponding to the granularity.

For example, with a scheduling granularity of 10 ms, sleeping for durations between 0 (excluded) and 10 ms (excluded) would result on an idle computer in a 10 ms sleep.

Note:
The computation is done one time for all. It may last up to a few seconds. Next calls to this method will return almost immediately this precomputed value.

If the computer is loaded with other demanding processes, then the computed time slice will not be the kernel basic time slice (say, 10 ms) but an average time slice availability (say, 14 ms) since other processes use CPU time too. It is however the intended behaviour since this user application needs to rely on an actual availability rather than a theoritical one. This granularity will be relevant as long as the computer load will remain relatively constant during the application execution.

Typically, on Linux 2.4 kernels, the returned value on idle computers should be about 10 000 (microseconds), i.e. 10 ms.

On Linux 2.6 kernels, the expected result (1 ms) is seldom found, the measures show on some computers a first stage, quite irregular, at 4 ms, with next stages at 8, 12, 16 ms etc., which are quite stable. The algorithm detects then a 8 ms granularity, which is recommended, as in the 4 ms stage (reached for requests between 0 and 4 ms), there is often a peak: asking for 0.5 ms yields a reproducible 25 ms sleeps!

Hence requesting 0.9*granularity should yied a reliable minimal waiting. Note that its duration will in most cases not be what was requested. For example, with a granularity reliably measured at 8 ms (ex: 7994 microsec), one should request 8000*0.9=7200 microsec and have a (reliable) 6500 microsec sleep instead.

Note:
One may force a first call to this method to have the granularity precomputed one time for all, at start-up.
Exceptions:
SystemException if the operation is not supported (file descriptor feature is needed) or if the measurement failed.

Upper bound to time slice is 110 ms, to be able to catch as high as a 100 ms granularity (a frequency of less than 10Hz should be quite uncommon).

Definition at line 1799 of file CeylanSystem.cc.

References Ceylan::Maths::Abs(), Ceylan::System::File::close(), Ceylan::System::File::Create(), dataUtils::f, getActualDurationForSleep(), Ceylan::toString(), generalUtils::true, and Ceylan::System::File::write().

Referenced by atomicSleep(), and smartSleep().

UnsignedLongInteger Ceylan::System::getSecondsSinceSystemBoot (  ) 

Returns the uptime, the number of seconds since the system booted.

Exceptions:
SystemException on error, or if not implemented for this platform.

Definition at line 97 of file CeylanSystemInformation.cc.

References explainError().

UnsignedLongInteger Ceylan::System::getSharedMemorySize (  ) 

Returns the size of memory currently being shared, in bytes.

Exceptions:
SystemException on error, or if not implemented for this platform.

Definition at line 484 of file CeylanSystemInformation.cc.

References explainError(), and getTotalSystemMemorySize().

string Ceylan::System::getShellName (  ) 

Returns the name of the default shell, if found, otherwise returns an empty string.

This is done by reading environment variable 'SHELL'.

Note:
Some badly behaving shells, or old ones, do not set SHELL or use a misleading value.

Definition at line 227 of file CeylanSystem.cc.

References getEnvironmentVariable().

Second Ceylan::System::getTime (  ) 

Returns the current time since the Epoch (00:00:00 UTC, January 1, 1970), measured in seconds.

Note:
Will cause an overflow after year 2038.
See also:
Ceylan::Timestamp to easily access the correct local time.

Definition at line 832 of file CeylanSystem.cc.

References explainError(), and getError().

Referenced by Ceylan::Timestamp::Timestamp(), and Ceylan::Log::LogAggregatorHTML::WriteChannelFooter().

UnsignedLongInteger Ceylan::System::getTotalHighMemorySize (  ) 

Returns the total size of usable high memory, in bytes.

Exceptions:
SystemException on error, or if not implemented for this platform.

Definition at line 394 of file CeylanSystemInformation.cc.

References explainError().

Ceylan::Uint32 Ceylan::System::getTotalProcessCount (  ) 

Returns the current number of running processes.

Exceptions:
SystemException on error, or if not implemented for this platform.

Definition at line 133 of file CeylanSystemInformation.cc.

References explainError().

UnsignedLongInteger Ceylan::System::getTotalSwapMemorySize (  ) 

Returns the total size of swap memory, in bytes.

Exceptions:
SystemException on error, or if not implemented for this platform.

Definition at line 304 of file CeylanSystemInformation.cc.

References explainError().

UnsignedLongInteger Ceylan::System::getTotalSystemMemorySize (  ) 

Returns the total size of usable main memory, in bytes.

Exceptions:
SystemException on error, or if not implemented for this platform.

Definition at line 178 of file CeylanSystemInformation.cc.

References explainError().

Referenced by getSharedMemorySize().

UnsignedLongInteger Ceylan::System::getUsedSystemMemorySize (  ) 

Returns the size of main memory being currently used, in bytes.

Exceptions:
SystemException on error, or if not implemented for this platform.
See also:
getFreeSystemMemorySize

Definition at line 277 of file CeylanSystemInformation.cc.

string Ceylan::System::GetUserName (  ) 

Returns the name of the user, as retrieved from the system.

Exceptions:
SystemException on error, or if not implemented for this platform.
On the Nintendo DS, textual personal data is stored in UTF-16, hence the management of some non-ASCII characters might be incorrect.

On the NoCachGBA emulator, an empty string is returned.

Definition at line 581 of file CeylanSystemInformation.cc.

bool Ceylan::System::HasAvailableData ( FileDescriptor  fd  ) 

Tells whether there is data available on specified file descriptor.

Definition at line 515 of file CeylanSystem.cc.

References explainError(), and generalUtils::false.

Referenced by Ceylan::Network::Socket::hasAvailableData(), and Ceylan::System::Pipe::hasAvailableData().

void Ceylan::System::InitializeInterrupts ( bool  force = false  ) 

On platforms requiring it (ex: the Nintendo DS), initializes the interrupt system by using a default handler.

Parameters:
force if true, the handler will be reset unconditionnally, if false it will be reset only if not already set (allows to perform it once for all at startup).
Exceptions:
SystemException if an error occurred (if on the platform nothing has to be done, only a log warning will be issued, no exception will be thrown).

Definition at line 244 of file CeylanSystem.cc.

References generalUtils::false, and generalUtils::true.

Referenced by atomicSleep(), basicSleep(), Ceylan::System::FIFO::FIFO(), Ceylan::getChar(), and Ceylan::keyboardHit().

void Ceylan::System::InitializeIPC (  ) 

On platforms requiring it (ex: the Nintendo DS), initializes the IPC system (Inter-Process Communication), by setting up the FIFO infrastructure (creation and activation).

Note:
Creates a default FIFO with no application-specific requests supported. If the user subclassed the FIFO mother class to support additional commands, it has to be initialized by user code instead.
Exceptions:
SystemException if an error occurred (if on the platform nothing has to be done, only a log warning will be issued, no exception will be thrown).

Definition at line 322 of file CeylanSystem.cc.

References Ceylan::System::FIFO::activate().

bool Ceylan::System::isEnvironmentVariableSet ( const std::string &  variableName  ) 

Returns whether the specified environment variable is set.

Definition at line 46 of file CeylanEnvironmentVariables.cc.

References getEnvironmentVariable().

bool Ceylan::System::openGLContextsCanBeLost (  ) 

Tells whether the OpenGL contexts can be lost (and therefore may have to be reloaded) under certain unexpected circumstances (ex : window resize, going to fullscreen, switching to another application, etc.

) on the current platform, without specific notice.

On some platforms, the OpenGL contexts can be lost when :

  • window resizing/changing resolutions, including going to fullscreen
  • switching to another application
  • changing color depth

Exceptions:
SystemException on error, or if not known for this platform.

Definition at line 716 of file CeylanSystemInformation.cc.

References openGLContextsLostOnApplicationSwitch(), openGLContextsLostOnColorDepthChange(), and openGLContextsLostOnResize().

bool Ceylan::System::openGLContextsLostOnApplicationSwitch (  ) 

Tells whether the OpenGL contexts are lost (and therefore may have to be reloaded) when switching to another application.

Exceptions:
SystemException on error, or if not known for this platform.

Definition at line 755 of file CeylanSystemInformation.cc.

References generalUtils::false, and generalUtils::true.

Referenced by openGLContextsCanBeLost().

bool Ceylan::System::openGLContextsLostOnColorDepthChange (  ) 

Tells whether the OpenGL contexts are lost (and therefore may have to be reloaded) when changing the color depth.

Exceptions:
SystemException on error, or if not known for this platform.

Definition at line 783 of file CeylanSystemInformation.cc.

References generalUtils::false, and generalUtils::true.

Referenced by openGLContextsCanBeLost().

bool Ceylan::System::openGLContextsLostOnResize (  ) 

Tells whether the OpenGL contexts are lost (and therefore may have to be reloaded) when the window application is resized (resolution changed).

Exceptions:
SystemException on error, or if not known for this platform.

Definition at line 727 of file CeylanSystemInformation.cc.

References generalUtils::false, and generalUtils::true.

Referenced by openGLContextsCanBeLost().

InterruptMask Ceylan::System::SetEnabledInterrupts ( InterruptMask  newMask = AllInterruptsDisabled  ) 

On platforms supporting it (ex: the Nintendo DS on the ARM9), sets the current set of interrupts enabled.

Parameters:
newMask the masks describing all the interrupts that are to be enabled. By default (no parameter specified), all will be disabled.
Returns:
The previous mask that was used, before being replaced by the specified one.
Exceptions:
SystemException if an error occurred.

Definition at line 295 of file CeylanSystem.cc.

Referenced by Ceylan::System::FIFO::activate(), Ceylan::System::FIFO::deactivate(), Ceylan::System::FIFO::sendBatteryStatusRequest(), and Ceylan::System::FIFO::sendDSTypeRequest().

void Ceylan::System::setEnvironmentVariable ( const std::string &  variableName,
const std::string &  variableValue 
)

Sets specified environment variable to the specified value.

Exceptions:
UtilsException if an error occured, which is very rare, and should be due to insufficient memory space to allocate the new environment.

Definition at line 111 of file CeylanEnvironmentVariables.cc.

References explainError().

Referenced by unsetEnvironmentVariable().

bool Ceylan::System::setLegacyStreamSynchronization ( bool  synchronized  ) 

Sets whether the C++ standard streams (cin, cout, cerr, clog, and their wide-character counterparts) should be synchronized with their C-stream counterparts (this is the default situation).

Deactivating synchronization leads to substancial gains of speed for I/O operations operating on these streams, at the price of using only C++ streams (therefore the C-stream counterparts should not be used at all).

Parameters:
synchronized if true, ensures C and C++ streams are synchronized (the default), if false no specific synchonization is performed.
Returns:
the previous synchronization status.
Note:
Should be called before performing any I/O via the C++ stream objects.

It is unclear whether file I/O can be impacted.

Definition at line 2036 of file CeylanSystem.cc.

void Ceylan::System::sleepForSeconds ( Second  secondCount  ) 

Sleeps for the specified number of seconds.

It makes the current process sleep until secondCount seconds have elapsed or a signal arrives which is not ignored.

Exceptions:
SystemException if the sleep failed.
See also:
basicSleep methods for far better accuracy.

Definition at line 1163 of file CeylanSystem.cc.

References basicSleep().

bool Ceylan::System::smartSleep ( Second  secondCount,
Microsecond  microCount 
)

Makes the process smartly sleep for the specified duration.

Smart sleep is the result of as many basic sleeps as needed to wait for the main part of the specified duration (which is the result of the integer division of the requested duration by the guessed time slice duration), followed by active waiting to complete the remaining part of the specified waiting time. Finally, the process should wait for the specified time with as small as possible resource use, and with a precision of a few microseconds, on a not too heavily loaded computer.

Note:
As much as possible, no active polling is made to save CPU cycles for other processes and to save laptop batteries. Fine grained waiting is nevertheless performed, with one big sleeping duration, supplemented by as many one-slice sleeps as needed to end up with the last time slice and the remaining sub-slice time being spent in active waiting.

A preliminary call to getSchedulingGranularity should be performed first, so that the time slice evaluation, which is a lengthy process, is done before actual run. Otherwise the first call to smartSleep would return too late.

Parameters:
secondCount the number of seconds to wait, should be in the range 0 to 4200 to avoid overflow. For longer periods, use multiple calls to smartSleep.
microCount the remaining part of the time to wait, expressed as a number of microseconds. As full seconds should be taken into account with the parameter seconds, micros should be less than one second, i.e. should be in the range 0 to 10E6 - 1.
Returns:
whether the deadline was successfully met, i.e. if the waiting was on schedule.
Exceptions:
SystemException if a system call failed or if the necessary file descriptor feature is not available.
See also:
Ceylan::Features::areFileDescriptorsSupported to check it prior to calling this sleep method.

Definition at line 1410 of file CeylanSystem.cc.

References atomicSleep(), basicSleep(), generalUtils::false, getPreciseTime(), getPreciseTimeCallDuration(), getSchedulingGranularity(), OneMillion, Ceylan::toString(), and generalUtils::true.

Referenced by smartSleepUntil().

bool Ceylan::System::smartSleepUntil ( Second  secondCount,
Microsecond  microCount 
)

Makes the process smartly sleep until the specified time arrives.

Parameters:
secondCount the number of seconds to wait for.
microCount the microsecond to wait for, expressed as a number of microseconds. As full seconds should be taken into account with the parameter second, micros should be less than one second, i.e. should be in the range 0 to 10E6 - 1.
Note:
Uses smartSleep
Exceptions:
SystemException if a system call failed, or if specified time is in the past, or if the necessary file descriptor feature is not available.
See also:
Ceylan::Features::areFileDescriptorsSupported to check it prior to calling this sleep method.

Definition at line 1727 of file CeylanSystem.cc.

References getPreciseTime(), OneMillion, smartSleep(), and Ceylan::toString().

string Ceylan::System::timeToString ( const time_t &  t  ) 

Converts the time moment into a human readable string.

Exceptions:
SystemException if the conversion is not available or failed.
See also:
Ceylan::Timestamp to easily output the correct local time.

Definition at line 862 of file CeylanSystem.cc.

Referenced by Ceylan::Log::LogAggregatorHTML::WriteChannelFooter().

void Ceylan::System::unsetEnvironmentVariable ( const std::string &  variableName  ) 

Unsets specified environment variable.

Exceptions:
UtilsException if an error occured, which is very rare.

Definition at line 176 of file CeylanEnvironmentVariables.cc.

References setEnvironmentVariable().


Variable Documentation

The maximum number of seconds for durations to be evaluated with a microsecond accuracy, before an overflow may occur.

Definition at line 181 of file CeylanSystem.cc.

Referenced by getDurationBetween().


Generated on Thu Jun 4 20:40:45 2009 for Ceylan by  doxygen 1.5.8