Skip to content

Commit

Permalink
Convert ProtocolParallelJobState enum to StringId.
Browse files Browse the repository at this point in the history
Allows removal of protocolParallelJobToConstZ(), which was used only for debugging.
  • Loading branch information
dwsteele committed Apr 28, 2021
1 parent 85fc3da commit bd68ed6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 33 deletions.
1 change: 1 addition & 0 deletions doc/xml/release.xml
Expand Up @@ -93,6 +93,7 @@
<commit subject="Update CipherType/CipherMode to StringId.">
<github-pull-request id="1384"/>
</commit>
<commit subject="Convert ProtocolParallelJobState enum to StringId."/>

<release-item-contributor-list>
<release-item-reviewer id="cynthia.shang"/>
Expand Down
2 changes: 1 addition & 1 deletion src/protocol/parallel.c
Expand Up @@ -277,6 +277,6 @@ String *
protocolParallelToLog(const ProtocolParallel *this)
{
return strNewFmt(
"{state: %s, clientTotal: %u, jobTotal: %u}", protocolParallelJobToConstZ(this->state), lstSize(this->clientList),
"{state: %s, clientTotal: %u, jobTotal: %u}", strZ(strIdToStr(this->state)), lstSize(this->clientList),
lstSize(this->jobList));
}
32 changes: 4 additions & 28 deletions src/protocol/parallelJob.c
Expand Up @@ -117,7 +117,7 @@ protocolParallelJobStateSet(ProtocolParallelJob *this, ProtocolParallelJobState
{
FUNCTION_LOG_BEGIN(logLevelTrace);
FUNCTION_LOG_PARAM(PROTOCOL_PARALLEL_JOB, this);
FUNCTION_LOG_PARAM(ENUM, state);
FUNCTION_LOG_PARAM(STRING_ID, state);
FUNCTION_LOG_END();

ASSERT(this != NULL);
Expand All @@ -129,43 +129,19 @@ protocolParallelJobStateSet(ProtocolParallelJob *this, ProtocolParallelJobState
else
{
THROW_FMT(
AssertError, "invalid state transition from '%s' to '%s'", protocolParallelJobToConstZ(protocolParallelJobState(this)),
protocolParallelJobToConstZ(state));
AssertError, "invalid state transition from '%s' to '%s'", strZ(strIdToStr(protocolParallelJobState(this))),
strZ(strIdToStr(state)));
}

FUNCTION_LOG_RETURN_VOID();
}

/**********************************************************************************************************************************/
const char *
protocolParallelJobToConstZ(ProtocolParallelJobState state)
{
const char *result = NULL;

switch (state)
{
case protocolParallelJobStatePending:
result = "pending";
break;

case protocolParallelJobStateRunning:
result = "running";
break;

case protocolParallelJobStateDone:
result = "done";
break;
}

return result;
}

String *
protocolParallelJobToLog(const ProtocolParallelJob *this)
{
return strNewFmt(
"{state: %s, key: %s, command: %s, code: %d, message: %s, result: %s}",
protocolParallelJobToConstZ(protocolParallelJobState(this)), strZ(varToLog(protocolParallelJobKey(this))),
strZ(strIdToStr(protocolParallelJobState(this))), strZ(varToLog(protocolParallelJobKey(this))),
strZ(protocolCommandToLog(protocolParallelJobCommand(this))), protocolParallelJobErrorCode(this),
strZ(strToLog(protocolParallelJobErrorMessage(this))), strZ(varToLog(protocolParallelJobResult(this))));
}
9 changes: 5 additions & 4 deletions src/protocol/parallelJob.h
Expand Up @@ -4,6 +4,8 @@ Protocol Parallel Job
#ifndef PROTOCOL_PARALLEL_JOB_H
#define PROTOCOL_PARALLEL_JOB_H

#include "common/type/stringId.h"

/***********************************************************************************************************************************
Object type
***********************************************************************************************************************************/
Expand All @@ -14,9 +16,9 @@ Job state enum
***********************************************************************************************************************************/
typedef enum
{
protocolParallelJobStatePending,
protocolParallelJobStateRunning,
protocolParallelJobStateDone,
protocolParallelJobStatePending = STRID5("pending", 0x1dc9238b00),
protocolParallelJobStateRunning = STRID5("running", 0x1dc973ab20),
protocolParallelJobStateDone = STRID5("done", 0x2b9e40),
} ProtocolParallelJobState;

#include "common/time.h"
Expand Down Expand Up @@ -121,7 +123,6 @@ protocolParallelJobFree(ProtocolParallelJob *const this)
/***********************************************************************************************************************************
Macros for function logging
***********************************************************************************************************************************/
const char *protocolParallelJobToConstZ(ProtocolParallelJobState state);
String *protocolParallelJobToLog(const ProtocolParallelJob *this);

#define FUNCTION_LOG_PROTOCOL_PARALLEL_JOB_TYPE \
Expand Down

0 comments on commit bd68ed6

Please sign in to comment.