Jameo Core Library
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
jm::Thread Class Referenceabstract

Thread implementation. More...

Inheritance diagram for jm::Thread:
jm::Object

Public Member Functions

 Thread ()
 Default constructor.
 
 ~Thread () override
 Destructor.
 
void start ()
 This method starts the thread.
 
void sleep (int64 duration)
 This method puts the thread to sleep and wakes it up after the specified time has elapsed. The thread can also be woken up externally before the time has elapsed.
 
void sleep ()
 This method puts the thread to sleep. The thread must be externally awakened.
 
void wakeUp ()
 If the thread is sleeping, it will be woken up by calling this method.
 
void interrupt ()
 This method terminates the execution of this thread. It waits for the thread to finish execution ???
 
bool isAlive ()
 This method should be called regularly to check if the thread should be terminated. If this method returns false, the thread should be terminated.
 
void setName (const String &name)
 Set the name of the thread.
 
- Public Member Functions inherited from jm::Object
 Object () noexcept
 Constructor.
 
virtual ~Object () noexcept
 Destructor.
 
void release () noexcept
 Decreases the reference counter and releases the object immediately when the reference counter becomes 0.
 
Objectretain () noexcept
 Increases the reference counter of this object by 1.
 
Objectautorelease () noexcept
 Same function as release(), but releases the object with a delay if the reference counter is 0. AutoreleasePool::drain() must be called in the to release the object.
 
int32 referenceCount () const noexcept
 Returns the value of the reference counter.
 
virtual bool equals (const Object *other) const
 Comparison of objects.
 
virtual String displayName () const
 Returns the display name of the object intended to present to a user.
 
virtual void printDiffInfo (DiffOperation operation, Object *other) const
 Output method for outputting the diff results for the diff algorithm.
 
void setHighBit (bool status) noexcept
 
bool highBit () const noexcept
 

Static Public Member Functions

static bool isMainThread ()
 Checks if the current thread is the main thread.
 

Protected Member Functions

void lock ()
 This method blocks this thread from accessing other threads to mark a critical section that must not be interrupted or to avoid race conditions.
 
void unlock ()
 This method releases the lock held by this thread, allowing other threads to access the critical section. This is used to mark a critical section that must not be interrupted or to avoid race conditions.
 

Detailed Description

Thread implementation.

Constructor & Destructor Documentation

◆ Thread()

jm::Thread::Thread ( )

Default constructor.

◆ ~Thread()

jm::Thread::~Thread ( )
override

Destructor.

Member Function Documentation

◆ interrupt()

void jm::Thread::interrupt ( )

This method terminates the execution of this thread. It waits for the thread to finish execution ???

◆ isAlive()

bool jm::Thread::isAlive ( )

This method should be called regularly to check if the thread should be terminated. If this method returns false, the thread should be terminated.

Returns
Returns true if the thread should continue running.

◆ isMainThread()

static bool jm::Thread::isMainThread ( )
static

Checks if the current thread is the main thread.

◆ lock()

void jm::Thread::lock ( )
protected

This method blocks this thread from accessing other threads to mark a critical section that must not be interrupted or to avoid race conditions.

◆ setName()

void jm::Thread::setName ( const String name)

Set the name of the thread.

Note
This method is intended for help debugging.

◆ sleep() [1/2]

void jm::Thread::sleep ( )

This method puts the thread to sleep. The thread must be externally awakened.

◆ sleep() [2/2]

void jm::Thread::sleep ( int64  duration)

This method puts the thread to sleep and wakes it up after the specified time has elapsed. The thread can also be woken up externally before the time has elapsed.

Parameters
durationThe time duration (in milliseconds) for which the thread should sleep.

◆ start()

void jm::Thread::start ( )

This method starts the thread.

◆ unlock()

void jm::Thread::unlock ( )
protected

This method releases the lock held by this thread, allowing other threads to access the critical section. This is used to mark a critical section that must not be interrupted or to avoid race conditions.

◆ wakeUp()

void jm::Thread::wakeUp ( )

If the thread is sleeping, it will be woken up by calling this method.