from
Semaphore
by Kevin
Simple semaphore implementation wrapping around Matlab's waitfor.
|
| Semaphore
|
classdef Semaphore
%SEMAPHORE A blocking event handler
% Matlab's waitfor() command requires a figure. This makes it a bit
% easier to interface with so the code isn't as unusual.
properties (Access = private)
Figure
end
methods
function obj = Semaphore()
obj.Figure = figure('Visible', 'off');
obj.Lock();
end
function obj = Release(obj)
set(obj.Figure, 'UserData', false);
end
function obj = Lock(obj)
set(obj.Figure, 'UserData', true);
end
function obj = Wait(obj)
waitfor(obj.Figure, 'UserData', false);
end
function obj = delete(obj)
delete(obj.Figure);
end
end
end
|
|
Contact us