You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by ma...@apache.org on 2009/09/24 14:57:48 UTC
svn commit: r818468 - in /lucene/lucy/trunk/core/Lucy/Util: Sleep.bp Sleep.c
Author: marvin
Date: Thu Sep 24 12:57:48 2009
New Revision: 818468
URL: http://svn.apache.org/viewvc?rev=818468&view=rev
Log:
Commit LUCY-55, adding cross-platform-compatible sleep functions.
Added:
lucene/lucy/trunk/core/Lucy/Util/Sleep.bp (with props)
lucene/lucy/trunk/core/Lucy/Util/Sleep.c (with props)
Added: lucene/lucy/trunk/core/Lucy/Util/Sleep.bp
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Util/Sleep.bp?rev=818468&view=auto
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Util/Sleep.bp (added)
+++ lucene/lucy/trunk/core/Lucy/Util/Sleep.bp Thu Sep 24 12:57:48 2009
@@ -0,0 +1,31 @@
+
+/** Provide platform-compatible sleep() functions.
+ */
+inert class Lucy::Util::Sleep {
+
+ /** Sleep for <code>seconds</code> seconds.
+ */
+ inert void
+ sleep(u32_t seconds);
+
+ /** Sleep for <code>milliseconds</code> milliseconds.
+ */
+ inert void
+ millisleep(u32_t milliseconds);
+}
+
+/* Copyright 2009 The Apache Software Foundation
+ *
+ * Licensed 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.
+ */
+
Propchange: lucene/lucy/trunk/core/Lucy/Util/Sleep.bp
------------------------------------------------------------------------------
svn:eol-style = native
Added: lucene/lucy/trunk/core/Lucy/Util/Sleep.c
URL: http://svn.apache.org/viewvc/lucene/lucy/trunk/core/Lucy/Util/Sleep.c?rev=818468&view=auto
==============================================================================
--- lucene/lucy/trunk/core/Lucy/Util/Sleep.c (added)
+++ lucene/lucy/trunk/core/Lucy/Util/Sleep.c Thu Sep 24 12:57:48 2009
@@ -0,0 +1,60 @@
+#define C_LUCY_SLEEP
+#include "Lucy/Util/Sleep.h"
+
+/********************************* WINDOWS ********************************/
+#ifdef CHY_HAS_WINDOWS_H
+
+#include <windows.h>
+
+void
+lucy_Sleep_sleep(chy_u32_t seconds)
+{
+ Sleep(seconds * 1000);
+}
+
+void
+lucy_Sleep_millisleep(chy_u32_t milliseconds)
+{
+ Sleep(milliseconds);
+}
+
+/********************************* UNIXEN *********************************/
+#elif defined(CHY_HAS_UNISTD_H)
+
+#include <unistd.h>
+
+void
+lucy_Sleep_sleep(chy_u32_t seconds)
+{
+ sleep(seconds);
+}
+
+void
+lucy_Sleep_millisleep(chy_u32_t milliseconds)
+{
+ chy_u32_t seconds = milliseconds / 1000;
+ milliseconds = milliseconds % 1000;
+ sleep(seconds);
+ /* TODO: probe for usleep. */
+ usleep(milliseconds * 1000);
+}
+
+#else
+ #error "Can't find a known sleep API."
+#endif /* OS switch. */
+
+/* Copyright 2009 The Apache Software Foundation
+ *
+ * Licensed 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.
+ */
+
Propchange: lucene/lucy/trunk/core/Lucy/Util/Sleep.c
------------------------------------------------------------------------------
svn:eol-style = native