Be the first to rate this file! 3 Downloads (last 30 days) File Size: 1.26 KB File ID: #42910

Semaphore

by Kevin

 

01 Aug 2013

Simple semaphore implementation wrapping around Matlab's waitfor.

| Watch this File

File Information
Description

Matlab has a waitfor function but it only works if you have a figure handle, leading to some somewhat out-of-place code if you want to use it with callbacks.

Semaphore.m is a simple wrapper around waitfor to make downstream code a little cleaner. To use it, create a Semaphore object. If this object is passed to an event handler or timer, then that handler can call Semaphore.Release() when it's finished.

If another thread as a Semaphore.Wait() call, it will wait until the respective Semaphore has been released.

Inspired by http://www.mathworks.com/matlabcentral/fileexchange/32489-semaphore, but I wanted something that didn't require an external library.

Acknowledgements

Semaphore inspired this file.

Required Products MATLAB
MATLAB release MATLAB 8.1 (R2013a)
Tags for This File  
Everyone's Tags
callback, event, lock, semaphore, wait
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.

Contact us