Difference between revisions of "Sead/Locks"

From Deep Sea Knowledge
Jump to navigation Jump to search
(Make page with CriticalSection)
 
m
Line 30: Line 30:
 
};
 
};
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
 +
 +
[[Category:Sead (Library)]]

Revision as of 23:17, 27 December 2018

Lock classes that are contained in the sead namespace are classified as classes that pertain to locking regions of memory or data to prevent accidental mishandling.

CriticalSection

CriticalSection is a class that contains a region of code that is executed in isolation from other code, optionally with respect to it, within the executable. It inherits from the IDisposer class.

namespace sead
{
    class CriticalSection : sead::IDisposer
    {
    public:
        // default constructor. Initializes the stored mutex type.
        CriticalSection();
        // constructor that initializes the section disposer with a heap and initializes the stored mutex type.
        CriticalSection(sead::Heap *);
        // constructor that initializes the section disposer with a heap and a null option, and initializes the mutex type.
        CriticalSection(sead::Heap *, sead::IDisposer::HeapNullOption);
        // destructor
        ~CriticalSection();

        // locks the section
        void lock();
        // attempts to lock the section, True is successful, False if failure
        bool tryLock();
        // unlock the section
        void unlock();

        nn::os::MutexType* mMutexType; // _20
    };
};