Wiki Page Content

Differences between revisions 3 and 4
Revision 3 as of 2011-02-01 20:46:42
Size: 757
Editor: SheenaSmith
Comment: update content - remove acl
Revision 4 as of 2011-02-02 18:20:09
Size: 758
Editor: SheenaSmith
Comment: update content - w/ Sam; remove draft
Deletions are marked like this. Additions are marked like this.
Line 3: Line 3:
||<tablewidth="100%" style="color: #FF0000;" :> DRAFT||
Line 16: Line 15:
||'''lock'''||points to the lock|| ||'''lock'''||a pointer to a lock variable||
Line 27: Line 26:
''You can add useful comments here'' <<Include(CategoryAtomic, , , from="Start Include here.", to="##End Include here")>>

SDL_AtomicTryLock

Use this function to try to lock a spin lock by setting it to a non-zero value.

Syntax

SDL_bool SDL_AtomicTryLock(SDL_SpinLock* lock)

Function Parameters

lock

a pointer to a lock variable

Return Value

Returns SDL_TRUE if the lock succeeded, SDL_FALSE if the lock is already held.

Code Examples

You can add your code example here

Remarks

The atomic locks are efficient spinlocks using CPU instructions, but are vulnerable to starvation and can spin forever if a thread holding a lock has been terminated. For this reason you should minimize the code executed inside an atomic lock and never do expensive things like API or system calls while holding them.

/!\ The atomic locks are not safe to lock recursively.


CategoryAPI, CategoryAtomic

None: SDL_AtomicTryLock (last edited 2011-02-02 18:20:09 by SheenaSmith)

(Page Info.)
Feedback
Please include your contact information if you'd like to receive a reply.
Submit