You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by GitBox <gi...@apache.org> on 2020/07/10 20:22:10 UTC

[GitHub] [beam] robertwb commented on a change in pull request #12172: [BEAM-10185] Building python wheels for Windows (on Github Actions)

robertwb commented on a change in pull request #12172:
URL: https://github.com/apache/beam/pull/12172#discussion_r453058533



##########
File path: sdks/python/apache_beam/runners/worker/crossplatform_time.h
##########
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef BEAM_CROSSPLATFORM_TIME_H
+#define BEAM_CROSSPLATFORM_TIME_H
+
+#include <time.h>
+
+#ifdef _WIN32
+#include <windows.h>
+
+/**
+ * Alternative to POSIX clock_gettime that may be run on Windows platform. The clk_id parameter is
+ * ignored, and function always act as for CLOCK_MONOTONIC. Windows performance counter is used.
+ */
+int clock_gettime(int clk_id, struct timespec *tv) {
+    static LARGE_INTEGER counterFrequency = {0};
+    LARGE_INTEGER counterValue;
+
+    if (0 == counterFrequency.QuadPart) {
+        if (0 == QueryPerformanceFrequency(&counterFrequency)) {
+            /* System doesn't support performance counters. It's guaranteed to not happen
+            on systems that run Windows XP or later */
+            return -1;

Review comment:
       These error codes are never checked by the callers. That would seem to give incorrect results (especially if timespec is initialized with random data (e.g. on the stack) each time. 
   
   Is there a simpler/more robust API we could call instead in this case, even if it is lower precision? 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org