/* * $Id: smartlock.h 160 2007-11-03 14:40:28Z hderuiter $ * * Performs smart locking of Warp3D to ensure that it doesn't block the rest of the system for to long. * * $Date: 2007-11-03 09:40:28 -0359ÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐÐ $ * $Revision: 000 $ * * (C) 2007 by Hans de Ruiter * All rights reserved * * This file is part of the MiniGL library project * See the file Licence.txt for more details * */ #ifndef __SMARTLOCK_H__ #define __SMARTLOCK_H__ #include #include #include #include typedef struct SmartLock_s { uint32 maxLockTime; // the maximum allowable lock time in microseconds GLuint maxTicks; GLuint warningTicks; GLcontext context; APTR drawingLock; int drawing; // 0 = not drawing, 1 = drawing, 2 or higher = nested smartlock_beginDraw() calls struct Task *mainThread; // Points to the thread that the smart-lock was created in struct Process *watchdogThread; uint32 watchdogThreadSigMask; uint32 watchdogThreadCancelSigMask; } SmartLock; /** Creates a new smart-lock object. * * @param maxLockTime the maximum allowable lock time in microseconds * @prarm context pointer to the context that this lock is associated with */ SmartLock* smartlock_new(uint32 maxLockTime, GLcontext context); /** Frees a smart-lock object. */ void smartlock_free(SmartLock *smartLock); /** Locks the hardware and starts the timer. * Be sure to call the smartlock_endDraw() function as soon as you're done with drawing the current primitive. * The smart-lock system won't unlock the hardware during a drawing operation, because it could lock up the * system. Calling smartlock_endDraw() indicates that it's safe to unlock the hardware if necessary. * * @return GLboolean true if the hardware was successfully locked */ GLboolean smartlock_beginDraw(SmartLock *smartLock); /** Called after a smartlock_beginDraw() call to indicate that drawing of the current primitive has finished. * The smart-lock system won't unlock the hardware during a drawing operation, because it could lock up the * system. Calling this function indicates that it's safe to unlock the hardware if necessary. * * @return GLboolean true if it unlocked the Warp3D context. */ GLboolean smartlock_endDraw(SmartLock *smartLock); /** Unlocks the hardware. This must be called outside a * smartlock_beginDraw()/smartlock_endDraw() pair. * * @return GLboolean true if it unlocked the Warp3D context. */ GLboolean smartlock_forceUnlock(SmartLock *smartLock); #endif