Created
January 15, 2013 22:43
-
-
Save malleor/4542884 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// in ExecuteManager::Execute: | |
// | |
IAlgorithm& v_alg = ... | |
ParamsIn v_in = ... | |
Context v_ctx = ... | |
// static data init | |
v_alg.Startup(v_ctx, v_in); | |
// execute across multiple threads | |
Workers v_workers(N, v_alg); // creates N threads and calls v_alg.Execute in each thread | |
// <- set up a callback for the worker pool (v_workers) | |
// | |
// in the worker pool finish callback: | |
// | |
ParamsOut v_out; | |
bool v_success = p_alg.Teardown(v_out); // collect output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <frames.h> | |
class AlgorithmA : | |
public IAlgorithm | |
{ | |
public: | |
AlgorithmA(); // ctor should be minimal | |
IAlgorithm::Manifest GetManifest() const; // author, version, mt (name not needed - it's 'moduleX.A') | |
bool Startup( // one-time call to Startup | |
IAlgorithm::Context& p_ctx, // executor, project, visualizer and log | |
const IAlgorithm::ParamsIn& p_in | |
); | |
void Execute( // Execute called once per worker thread | |
const IAlgorithm::ThreadInfo& p_thread // thread index, thread count (useful for thread-data mapping) | |
); | |
bool Teardown( // one-time call to Teardown | |
IAlgorithm::ParamsOut& p_out | |
); | |
} | |
extern "C" | |
__declspec(dllexport) | |
IAlgorithm* A() // algorithm 'moduleX.A' | |
{ | |
return new AlgorithmA(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment