Adun  0.83
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Public Member Functions
<AdMatrixModification> Protocol Reference

#import <AdMatrixModification.h>

Inheritance diagram for <AdMatrixModification>:
Inheritance graph

List of all members.

Public Member Functions

(BOOL) - allowsDirectModificationOfMatrix:
(BOOL) - matrixIsAvailableForModification:
(void) - object:willBeginWritingToMatrix:
(void) - object:didFinishWritingToMatrix:

Detailed Description

Protocol defining methods that should be implemented by objects if they wish to allow other objects to write directly to AdMatrix structs returned by their methods.

Usually AdMatrix structs returned by framework objects should not be modified directly. Instead objects which allow such modification provide set methods which copy the contents of another matrix into the struct.

This is necessary since these objects may need to perform internal tasks before and after modification of such matrices. If the matrices were modified directly the object would not know of the change and hence would not perform, usually critical, tasks. It is also necessary to maintain thread safety

However sometimes the extra efficency obtained through direct modification i.e. due to not having to maintain a separate matrix and not having to copy values from one matrix to another, is desirable. This protocol defines a way to enable direct modification while allowing the object that owns the matrix to perform updates and ensuring the resulting code is thread safe.

Objects who return modifiable #AdMatrix structs can implement the following methods which must be called by other objects before and after writing to the returned matrix.

Never directly write to a matrix whose owner does not provide access to it through this protocol

Member Function Documentation

- (BOOL) allowsDirectModificationOfMatrix: (AdMatrix *)  matrix

Should return YES if matrix, which is owned by the receiver, can be directly modified using the other methods of this protocol.

- (BOOL) matrixIsAvailableForModification: (AdMatrix *)  matrix

Returns YES if writes to matrix are currently locked due to it being modified from another thread. Returns NO otherwise. Note that even if this method returns YES a lock may be aquired by another thread in the interval between returning and a call to object:willBeginWritingToMatrix:

- (void) object: (id)  object
didFinishWritingToMatrix: (AdMatrix *)  matrix 

Sent by objects who have performed a direct write to matrix which is owned by the receiver. The receiver will perform any necessary updates before returning and unlock the matrix for writing by other threads.

- (void) object: (id)  object
willBeginWritingToMatrix: (AdMatrix *)  matrix 

Sent by objects who are about to perform a direct write to matrix which is owned by the receiver. The receiver will perform any necessary updates before returning. The receiver will only return when the matrix is not currently being modified from another thread.