diff --git a/dcapi/boinc/dc_boinc.h b/dcapi/boinc/dc_boinc.h index 844d29a40f..b45f26c4fc 100644 --- a/dcapi/boinc/dc_boinc.h +++ b/dcapi/boinc/dc_boinc.h @@ -103,6 +103,7 @@ struct _DC_Result DC_Workunit *wu; int exit_code; + double cpu_time; /* List of output files. Elements are of type DC_PhysicalFile */ GList *output_files; @@ -158,7 +159,7 @@ int _DC_initWUs(void) G_GNUC_INTERNAL; /* Creates a new DC_Result */ DC_Result *_DC_createResult(const char *wu_name, int db_id, - const char *xml_doc_in) G_GNUC_INTERNAL; + const char *xml_doc_in, double cpu_time) G_GNUC_INTERNAL; /* Destroys a DC_Result */ void _DC_destroyResult(DC_Result *result) G_GNUC_INTERNAL; diff --git a/dcapi/boinc/events.C b/dcapi/boinc/events.C index 3c90ec3457..ef507479bc 100644 --- a/dcapi/boinc/events.C +++ b/dcapi/boinc/events.C @@ -113,7 +113,8 @@ static int process_results(void) } /* Call the callback function */ - result = _DC_createResult(wu.name, wu.id, canonical_result.xml_doc_in); + result = _DC_createResult(wu.name, wu.id, + canonical_result.xml_doc_in, canonical_result.cpu_time); if (!result) { mark_wu_complete(wu, TRUE); @@ -302,7 +303,8 @@ static DC_MasterEvent *look_for_results(const char *wuFilter, const char *wuName event = g_new(DC_MasterEvent, 1); event->type = DC_MASTER_RESULT; - event->result = _DC_createResult(wu.name, wu.id, result.xml_doc_in); + event->result = _DC_createResult(wu.name, wu.id, result.xml_doc_in, + result.cpu_time); if (!event->result) { mark_wu_complete(wu, FALSE); diff --git a/dcapi/boinc/result.c b/dcapi/boinc/result.c index ed206774c7..4b9060b3f7 100644 --- a/dcapi/boinc/result.c +++ b/dcapi/boinc/result.c @@ -25,7 +25,7 @@ */ DC_Result *_DC_createResult(const char *wu_name, int db_id, - const char *xml_doc_in) + const char *xml_doc_in, double cpu_time) { DC_Result *result; GList *l; @@ -43,6 +43,7 @@ DC_Result *_DC_createResult(const char *wu_name, int db_id, result->wu->db_id = db_id; result->wu->state = DC_WU_FINISHED; + result->cpu_time = cpu_time; result->output_files = _DC_parseFileRefs(xml_doc_in, &result->num_outputs); @@ -198,3 +199,14 @@ char *DC_getResultOutput(const DC_Result *result, const char *logicalFileName) g_free(wuname); return NULL; } + +double DC_getResultCPUTime(const DC_Result *result) +{ + if (!result) + { + DC_log(LOG_ERR, "%s: Missing result", __func__); + return 0.0; + } + + return result->cpu_time; +} diff --git a/dcapi/doc/dc-sections.txt b/dcapi/doc/dc-sections.txt index c2c44a44a5..889d6080a6 100644 --- a/dcapi/doc/dc-sections.txt +++ b/dcapi/doc/dc-sections.txt @@ -103,5 +103,6 @@ DC_getResultCapabilities DC_getResultWU DC_getResultExit DC_getResultOutput +DC_getResultCPUTime diff --git a/dcapi/doc/tmpl/dc.sgml b/dcapi/doc/tmpl/dc.sgml index 7aaeda8e5d..83bbc6367e 100644 --- a/dcapi/doc/tmpl/dc.sgml +++ b/dcapi/doc/tmpl/dc.sgml @@ -40,7 +40,6 @@ Types of events the master application may receive. @DC_MASTER_RESULT: a new #DC_Result is available. @DC_MASTER_SUBRESULT: a subresult has arrived. @DC_MASTER_MESSAGE: a message has arrived. -@DC_MASTER_SUSPEND: a work unit has been suspended. @@ -104,14 +103,6 @@ as invalid. @message: contents of the message. - - -Prototype of the callback function used for reporting suspended work units. - - -@wu: the work unit that has been suspended. - - Initializes the master side of the DC-API. This function must be called first @@ -135,38 +126,6 @@ event. @msgcb: the callback for reporting messages. - - -Sets the callback function used for reporting messages. - - -@cb: the function to call when a message arrives. - - - - -Sets the callback function used for reporting results. - - -@cb: the function to call when a result is ready. - - - - -Sets the callback function used for reporting subresults. - - -@cb: the function to call when a subresult arrives. - - - - -Sets the callback function used for reporting suspended work units. - - -@cb: the function to call when a work unit has been suspended. - - Processes work unit events. In case of a work unit completes and its result is @@ -582,3 +541,18 @@ Returns the real path name for a logical output file name. string should be deallocated using free() when it is no longer needed. + + + Returns the CPU time used for computing the result, in seconds. + + + If redundant computing is enabled, only the CPU time of the canonical + result is returned. + + + + +@result: a #DC_Result. +@Returns: the CPU time needed to compute the result. + + diff --git a/dcapi/include/dc.h b/dcapi/include/dc.h index 69315e2682..4d12a3599a 100644 --- a/dcapi/include/dc.h +++ b/dcapi/include/dc.h @@ -208,6 +208,9 @@ int DC_getResultExit(const DC_Result *result); /* Returns the local name of an output file. */ char *DC_getResultOutput(const DC_Result *result, const char *logicalFileName); +/* Returns the CPU time used by the result. */ +double DC_getResultCPUTime(const DC_Result *result); + #ifdef __cplusplus } #endif