MDAT
1.0
|
Checker wrapper. More...
Public Member Functions | |
void | init (CheckerFuncPtr fn) |
Initializes the wrapper. More... | |
void | invoke (int id, string section) |
Invoke the checker. More... | |
Since each problem or program has their own unique synchronization requirements, the checker is external to MDAT. MDAT provides an interface for interacting with a checker via a callback function. The callback function must adhere to the following prototype and restrictions:
const char *checkerCallback(int id, const char *section, const char *property);
Parameters:
id
: The id of the thread.section
: The section that was just entered using mdat_enter_section or a special section (see below).property
: The type of thread – will be the same as the property specified when the thread was created using mdat_thread_start.The function should return NULL if the checker detects no errors and return an error message if an error was detected.
The checker wrapper will call the supplied checker (to init) at the following times:
ThreadStart
. This is used to initialize the checker for each thread.ThreadFinish
. This is used to alert the checker that a thread has finished.AllFinish
. This is used to alert the checker that all threads have finished.Note: When the last thread finishes, the checker is invoked twice – once with the section ThreadFinish
and then once with the section AllFinish
. In both cases, the thread id is the id of the last thread to finish.
When designing a checker, it is helpful to separate the functionality of the callback function based on different combinations of the section and the property. For a given section / property pair, the checker may do one or more of the following:
void CheckerWrapper::init | ( | CheckerFuncPtr | fn) |
Initializes the wrapper.
[in] | fn | checker function |
void CheckerWrapper::invoke | ( | int | id, |
string | section | ||
) |
Call the checker function. The id and section are passed directly into the checker.
[in] | id | thread id |
[in] | section | name of section |