[
https://issues.apache.org/jira/browse/GEODE-3136?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16246787#comment-16246787
]
ASF GitHub Bot commented on GEODE-3136:
---------------------------------------
mhansonp commented on a change in pull request #144: GEODE-3136: Convert time
values to std::chrono::duration.
URL: https://github.com/apache/geode-native/pull/144#discussion_r150121269
##########
File path: tests/cli/NewFwkLib/FunctionExecution/MyResultCollector.cs
##########
@@ -52,48 +52,47 @@ public MyResultCollector()
public void AddResult(TResult result)
{
m_addResultCount++;
- //CacheableArrayList rs = result as CacheableArrayList;
- //List<Object> rs = result as List<Object>;
- //for (int i = 0; i < rs.Count; i++)
- //{
- // m_results.Add(rs[i]);
- //}
m_results.Add(result);
}
public ICollection<TResult> GetResult()
{
- return GetResult(50);
+ return GetResult(TimeSpan.FromSeconds(50));
}
- public ICollection<TResult> GetResult(UInt32 timeout)
+ public ICollection<TResult> GetResult(TimeSpan timeout)
{
m_getResultCount++;
- if (m_resultReady == true)
- {
- return m_results;
- }
- else
+
+ lock(this)
{
- for (int i = 0; i < timeout; i++)
+ if (!m_resultReady)
{
- Thread.Sleep(1000);
- if (m_resultReady == true)
- {
- return m_results;
+ if (timeout > TimeSpan.Zero) {
+ if (!Monitor.Wait(this, timeout)) {
+ throw new FunctionExecutionException("Timeout waiting for
result.");
+ }
+ } else {
+ throw new FunctionExecutionException("Results not ready.");
}
}
- throw new FunctionExecutionException(
- "Result is not ready, endResults callback is called before
invoking getResult() method");
-
}
+
+ return m_results;
}
+
public void EndResults()
{
m_endResultCount++;
- m_resultReady = true;
+
+ lock (this) {
+ m_resultReady = true;
+ Monitor.Pulse(this);
+ }
}
+
public void ClearResults(/*bool unused*/)
{
m_results.Clear();
+ m_resultReady = false;
Review comment:
Is the lock here an intentional omission? I presume so.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Replace all public API time values with std::chrono types
> ---------------------------------------------------------
>
> Key: GEODE-3136
> URL: https://issues.apache.org/jira/browse/GEODE-3136
> Project: Geode
> Issue Type: Improvement
> Components: native client
> Reporter: Jacob S. Barrett
> Assignee: Jacob S. Barrett
>
> Remove ambiguity of time values by using
> [{{std::chrono}}|http://en.cppreference.com/w/cpp/chrono] types in the public
> API.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)