| 1 | # PySoy's _internals._sleep Function |
|---|
| 2 | # |
|---|
| 3 | # Copyright (C) 2006,2007,2008,2009 PySoy Group |
|---|
| 4 | # |
|---|
| 5 | # This program is free software; you can redistribute it and/or modify |
|---|
| 6 | # it under the terms of the GNU Affero General Public License as published |
|---|
| 7 | # by the Free Software Foundation, either version 3 of the License, or |
|---|
| 8 | # (at your option) any later version. |
|---|
| 9 | # |
|---|
| 10 | # This program is distributed in the hope that it will be useful, |
|---|
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 | # GNU Affero General Public License for more details. |
|---|
| 14 | # |
|---|
| 15 | # You should have received a copy of the GNU Affero General Public License |
|---|
| 16 | # along with this program; if not, see http://www.gnu.org/licenses |
|---|
| 17 | # |
|---|
| 18 | # $Id$ |
|---|
| 19 | |
|---|
| 20 | cdef void _sleep( unsigned int mseconds ) nogil : |
|---|
| 21 | # |
|---|
| 22 | # Cross-platform sleep function |
|---|
| 23 | # |
|---|
| 24 | # This is pretty straight-forward. |
|---|
| 25 | # We're using Microsoft's time units (1/1000th of a second) since it's |
|---|
| 26 | # the lowest common denominator between the two (usleep is 1/1000000th) |
|---|
| 27 | # |
|---|
| 28 | IF UNAME_SYSNAME == "Windows" : |
|---|
| 29 | # |
|---|
| 30 | # 1 Microsoft Way (TM) -- ugh |
|---|
| 31 | # |
|---|
| 32 | windows.Sleep(mseconds) |
|---|
| 33 | ELSE : |
|---|
| 34 | # |
|---|
| 35 | # Everyone else (GNU, Darwin, etc) |
|---|
| 36 | # |
|---|
| 37 | posix.usleep( mseconds * 1000 ) |
|---|