Remove Fl::*sleep() method family, as discussed in fltk.coredev.

Hopefully this doesn't break Windows or Mac OX IDE builds, please help
testing.

Short story: these functions showed compatibility problems, lacked some
quality (regarding interruption by signals), and maybe more.

This is a combined commit that reverts three (3) svn commits. The following
lists are extracted from git, but show the svn revisions and files:

    Remove Fl::*sleep() family, part 1: revert svn r 10287.

:100644 100644 a988702... 794920f... M	ide/Xcode4/FLTK.xcodeproj/project.pbxproj

    Remove Fl::*sleep() family, part 2: revert svn r 10151.

:100644 100644 cf839e6... bfde9c4... M	ide/Xcode3/FLTK.xcodeproj/project.pbxproj
:100644 100644 794920f... c0c772a... M	ide/Xcode4/FLTK.xcodeproj/project.pbxproj

    Remove Fl::*sleep() family, part 2b: revert svn r 10151 (continued).

:100644 100644 bfde9c4... abf2922... M	ide/Xcode3/FLTK.xcodeproj/project.pbxproj

    Remove Fl::*sleep() family, part 3: revert svn r 10150.

:100644 100644 b469018... e76a3e5... M	FL/Fl.H
:100644 100644 7bb7899... 4d4755d... M	ide/VisualC2008/fltk.lib.vcproj
:100644 100644 9d9a2cf... 334aef8... M	ide/VisualC2008/fltkdll.vcproj
:100644 100644 5533a54... e30058b... M	ide/VisualC2010/fltk.lib.vcxproj
:100644 100644 e49f691... 1259c87... M	ide/VisualC2010/fltk.lib.vcxproj.filters
:100644 100644 946f31a... d53ab80... M	src/CMakeLists.txt
:100644 000000 fed36fd... 0000000... D	src/Fl_sleep.cxx
:100644 100644 3d9656c... 3b265f9... M	src/Makefile
:100644 100644 6eadbcb... 5dd5872... M	test/sudoku.cxx


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@10419 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Albrecht Schlosser 2014-10-30 16:05:22 +00:00
parent 5772a1987c
commit 3e1da3012a
11 changed files with 10 additions and 188 deletions

10
FL/Fl.H
View File

@ -1153,16 +1153,6 @@ public:
static void awake(void* message = 0);
/** See void awake(void* message=0). */
static int awake(Fl_Awake_Handler cb, void* message = 0);
// Cross platform sleep API
/** flexible sleep function in seconds, accepts decimals typically up to 100usec resolution (depends on your hardware) */
static void sleep(double seconds);
/** milli seconds sleep */
static void msleep(unsigned long milliseconds);
/** microseconds sleep */
static void usleep(unsigned long long microseconds);
/**
The thread_message() method returns the last message
that was sent from a child by the awake() method.

View File

@ -3760,52 +3760,6 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\src\Fl_sleep.cxx"
>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BrowseInformation="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
FavorSizeOrSpeed="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug Cairo|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
BrowseInformation="1"
/>
</FileConfiguration>
<FileConfiguration
Name="Release Cairo|Win32"
>
<Tool
Name="VCCLCompilerTool"
FavorSizeOrSpeed="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\src\Fl_Menu.cxx"
>

View File

@ -3476,48 +3476,6 @@
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;FL_DLL;FL_LIBRARY;WIN32;NDEBUG;_WINDOWS;WIN32_LEAN_AND_MEAN;VC_EXTRA_LEAN;WIN32_EXTRA_LEAN;$(NoInherit)"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\src\Fl_sleep.cxx"
>
<FileConfiguration
Name="Release|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;FL_DLL;FL_LIBRARY;WIN32;NDEBUG;_WINDOWS;WIN32_LEAN_AND_MEAN;VC_EXTRA_LEAN;WIN32_EXTRA_LEAN;$(NoInherit)"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;FL_DLL;FL_LIBRARY;WIN32;_DEBUG;_WINDOWS;WIN32_LEAN_AND_MEAN;VC_EXTRA_LEAN;WIN32_EXTRA_LEAN;$(NoInherit)"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug Cairo|Win32"
>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;FL_DLL;FL_LIBRARY;WIN32;_DEBUG;_WINDOWS;WIN32_LEAN_AND_MEAN;VC_EXTRA_LEAN;WIN32_EXTRA_LEAN;$(NoInherit)"
/>
</FileConfiguration>
<FileConfiguration
Name="Release Cairo|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions="_CRT_SECURE_NO_DEPRECATE;FL_DLL;FL_LIBRARY;WIN32;NDEBUG;_WINDOWS;WIN32_LEAN_AND_MEAN;VC_EXTRA_LEAN;WIN32_EXTRA_LEAN;$(NoInherit)"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\..\src\Fl_Menu.cxx"

View File

@ -293,7 +293,6 @@
<ClInclude Include="..\..\FL\Fl_XPM_Image.H" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\Fl_sleep.cxx" />
<ClCompile Include="..\..\src\xutf8\case.c" />
<ClCompile Include="..\..\src\filename_absolute.cxx">
<Optimization Condition="'$(Configuration)|$(Platform)'=='Debug Cairo|Win32'">Disabled</Optimization>
@ -2520,4 +2519,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>

View File

@ -527,6 +527,5 @@
<ClCompile Include="..\..\src\scandir.c" />
<ClCompile Include="..\..\src\screen_xywh.cxx" />
<ClCompile Include="..\..\src\vsnprintf.c" />
<ClCompile Include="..\..\src\Fl_sleep.cxx" />
</ItemGroup>
</Project>

View File

@ -8,7 +8,6 @@
/* Begin PBXBuildFile section */
00BD4FD0209BFB1A6446B9A5 /* freeglut_teapot.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 95604163D1E6CBE33AAD66CD /* freeglut_teapot.cxx */; };
01C68DB0192C6089000BD75C /* Fl_sleep.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 01C68DAF192C6089000BD75C /* Fl_sleep.cxx */; };
023D5B2431F40114C118A5DB /* Fl_Window.cxx in Sources */ = {isa = PBXBuildFile; fileRef = BF1FE1C69D048AA23CF27B1E /* Fl_Window.cxx */; };
0262498E858406B6E51BD4E4 /* fl_symbols.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 7C8D88FDB0A0A32E59465025 /* fl_symbols.cxx */; };
036C655FFDAEEE93046F08A6 /* checkers.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 67989D22AB6482C5B577D395 /* checkers.cxx */; };
@ -4054,7 +4053,6 @@
00B08A2C8EA901C350696F8D /* Fl_compose.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Fl_compose.cxx; path = ../../src/Fl_compose.cxx; sourceTree = SOURCE_ROOT; };
00CAAA52DC3193E1133AE26C /* Fl_Float_Input.H */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Fl_Float_Input.H; path = ../../FL/Fl_Float_Input.H; sourceTree = SOURCE_ROOT; };
00E3864092375950FE42449E /* Fl_Tree_Item_Array.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Fl_Tree_Item_Array.cxx; path = ../../src/Fl_Tree_Item_Array.cxx; sourceTree = SOURCE_ROOT; };
01C68DAF192C6089000BD75C /* Fl_sleep.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Fl_sleep.cxx; path = ../../src/Fl_sleep.cxx; sourceTree = SOURCE_ROOT; };
020FFBC4E06A072BF8D098FB /* resize.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = resize.app; sourceTree = BUILT_PRODUCTS_DIR; };
02C21BB31E7DDFE9E76F4997 /* Fl_Dial.H */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Fl_Dial.H; path = ../../FL/Fl_Dial.H; sourceTree = SOURCE_ROOT; };
02EE866C628E67B0928F7E6C /* output.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = output.app; sourceTree = BUILT_PRODUCTS_DIR; };
@ -5545,7 +5543,6 @@
EB5B18A1B9B1E41F2AB56A97 /* Fl_get_system_colors.cxx */,
28E8F2802DEA5334F914BE98 /* Fl_grab.cxx */,
D004B2D87C53E063F848C539 /* Fl_lock.cxx */,
01C68DAF192C6089000BD75C /* Fl_sleep.cxx */,
AAE8D31DC4F024028C66743C /* Fl_own_colormap.cxx */,
5B2B6ED6A3649923BAAFFDF1 /* Fl_visual.cxx */,
09A359CA8F522F64BAF6CEAF /* Fl_x.cxx */,
@ -9530,7 +9527,6 @@
9DD7A2B6D63D30C07781F446 /* is_spacing.c in Sources */,
299CB8A2848CB844BCEC7829 /* Fl_Paged_Device.cxx in Sources */,
7F74F393190D7F0500C56950 /* fl_gleam.cxx in Sources */,
01C68DB0192C6089000BD75C /* Fl_sleep.cxx in Sources */,
7F76E016192FAD420071728B /* Fl_Copy_Surface.cxx in Sources */,
7F76E018192FAD590071728B /* Fl_Image_Surface.cxx in Sources */,
);

View File

@ -318,7 +318,6 @@
7EA88708B9A088FCEB7CAA27 /* file_chooser.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 39CD231E22E0B53E92CABDC9 /* file_chooser.cxx */; };
7EC3AD9A56535A54430B8DCD /* Fl_Browser_.cxx in Sources */ = {isa = PBXBuildFile; fileRef = AAD25B747F4122A2C5224708 /* Fl_Browser_.cxx */; };
7F12FCC718E1EEB900AB6A11 /* fl_gleam.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 7F12FCC618E1EEB900AB6A11 /* fl_gleam.cxx */; };
7F1373FF19BCC32E0020C0E5 /* Fl_sleep.cxx in Sources */ = {isa = PBXBuildFile; fileRef = 01BAFF0F192C611E005C6310 /* Fl_sleep.cxx */; };
7F4762EE12D22C470073A4F9 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7F4762ED12D22C470073A4F9 /* ApplicationServices.framework */; };
7F54C8A8130FAC4F00E736F3 /* gzclose.c in Sources */ = {isa = PBXBuildFile; fileRef = 7F54C8A3130FAC4F00E736F3 /* gzclose.c */; };
7F54C8A9130FAC4F00E736F3 /* gzlib.c in Sources */ = {isa = PBXBuildFile; fileRef = 7F54C8A4130FAC4F00E736F3 /* gzlib.c */; };
@ -4044,7 +4043,6 @@
00B08A2C8EA901C350696F8D /* Fl_compose.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Fl_compose.cxx; path = ../../src/Fl_compose.cxx; sourceTree = SOURCE_ROOT; };
00CAAA52DC3193E1133AE26C /* Fl_Float_Input.H */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Fl_Float_Input.H; path = ../../FL/Fl_Float_Input.H; sourceTree = SOURCE_ROOT; };
00E3864092375950FE42449E /* Fl_Tree_Item_Array.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Fl_Tree_Item_Array.cxx; path = ../../src/Fl_Tree_Item_Array.cxx; sourceTree = SOURCE_ROOT; };
01BAFF0F192C611E005C6310 /* Fl_sleep.cxx */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Fl_sleep.cxx; path = ../../src/Fl_sleep.cxx; sourceTree = "<group>"; };
020FFBC4E06A072BF8D098FB /* resize.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = resize.app; sourceTree = BUILT_PRODUCTS_DIR; };
02C21BB31E7DDFE9E76F4997 /* Fl_Dial.H */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = Fl_Dial.H; path = ../../FL/Fl_Dial.H; sourceTree = SOURCE_ROOT; };
02EE866C628E67B0928F7E6C /* output.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = output.app; sourceTree = BUILT_PRODUCTS_DIR; };
@ -5539,7 +5537,6 @@
EB5B18A1B9B1E41F2AB56A97 /* Fl_get_system_colors.cxx */,
28E8F2802DEA5334F914BE98 /* Fl_grab.cxx */,
D004B2D87C53E063F848C539 /* Fl_lock.cxx */,
01BAFF0F192C611E005C6310 /* Fl_sleep.cxx */,
AAE8D31DC4F024028C66743C /* Fl_own_colormap.cxx */,
5B2B6ED6A3649923BAAFFDF1 /* Fl_visual.cxx */,
09A359CA8F522F64BAF6CEAF /* Fl_x.cxx */,
@ -9473,7 +9470,6 @@
644FEEF43A0CCBD89E2CE6FC /* Fl_Table_Row.cxx in Sources */,
CDCB453B3493D8E96E80DFF7 /* Fl_Tabs.cxx in Sources */,
FB93EB94C997FC6F8C5D389D /* Fl_Text_Buffer.cxx in Sources */,
7F1373FF19BCC32E0020C0E5 /* Fl_sleep.cxx in Sources */,
4536387C357FBA58B3C5258B /* Fl_Text_Display.cxx in Sources */,
8F77031B8CCFF315D4CB151E /* Fl_Text_Editor.cxx in Sources */,
E21880F92CD1B5E315C3F4DF /* Fl_Tile.cxx in Sources */,

View File

@ -94,7 +94,6 @@ set(CPPFILES
Fl_get_system_colors.cxx
Fl_grab.cxx
Fl_lock.cxx
Fl_sleep.cxx
Fl_own_colormap.cxx
Fl_visual.cxx
Fl_x.cxx

View File

@ -1,68 +0,0 @@
//
// "$Id$"
//
// Multi-platform sleep functions for the Fast Light Tool Kit (FLTK).
//
// Copyright 1998-2014 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
// file is missing or damaged, see the license at:
//
// http://www.fltk.org/COPYING.php
//
// Please report all bugs and problems on the following page:
//
// http://www.fltk.org/str.php
//
// Cross platform sleep API for FLTK, F. Costantini, May 20th, 2014
#include <FL/Fl.H>
#include <config.h>
#include <stdlib.h>
#ifdef WIN32
#include <windows.h>
#else
#include <unistd.h>
#endif
/** Make the current thread sleep for n seconds, support decimals ... */
void Fl::sleep(double seconds)
{
Fl::usleep((unsigned long long) (seconds*1000000));
}
/** Make the current thread to sleep for n milliseconds */
void Fl::msleep(unsigned long milliseconds)
{
#ifdef WIN32
::Sleep( (DWORD) milliseconds);
#else
::usleep((useconds_t) (milliseconds*1000));
#endif
}
/** Make the current thread to sleep for n microseconds */
void Fl::usleep(unsigned long long microseconds)
// unsigned long long more should be more portable than int64_t before c++ 2011 ...
{
#ifdef WIN32
HANDLE timer;
LARGE_INTEGER reltime;
reltime.QuadPart = (LONGLONG) -(10*microseconds); // Convert to 100 nanosecond relative time interval
timer = CreateWaitableTimer(NULL, TRUE, NULL);
SetWaitableTimer(timer, &reltime, 0, NULL, NULL, 0);
WaitForSingleObject(timer, INFINITE);
CloseHandle(timer);
#else
::usleep((useconds_t) microseconds);
#endif
}
//
// End of "$Id$".
//

View File

@ -61,7 +61,7 @@ CPPFILES = \
Fl_Pack.cxx \
Fl_Paged_Device.cxx \
Fl_Pixmap.cxx \
Fl_PostScript.cxx \
Fl_PostScript.cxx \
Fl_Positioner.cxx \
Fl_Preferences.cxx \
Fl_Printer.cxx \
@ -110,7 +110,6 @@ CPPFILES = \
Fl_get_system_colors.cxx \
Fl_grab.cxx \
Fl_lock.cxx \
Fl_sleep.cxx \
Fl_own_colormap.cxx \
Fl_visual.cxx \
Fl_x.cxx \

View File

@ -418,19 +418,19 @@ SudokuSound::audio_cb(AudioDeviceID device,
}
#endif // __APPLE__
#define NOTE_DURATION_MS 50
#define NOTE_DURATION 50
// Play a note for 250ms...
// Play a note for <NOTE_DURATION> ms...
void SudokuSound::play(char note) {
Fl::check();
#ifdef __APPLE__
// Point to the next note...
data = sample_data[note - 'A'];
remaining = sample_size * 2;
// Wait for the sound to complete...
Fl::msleep(NOTE_DURATION_MS);
usleep(NOTE_DURATION*1000);
#elif defined(WIN32)
if (sample_size) {
@ -438,8 +438,8 @@ void SudokuSound::play(char note) {
waveOutWrite(device, header_ptr, sizeof(WAVEHDR));
Fl::msleep(NOTE_DURATION_MS);
} else Beep(frequencies[note - 'A'], NOTE_DURATION_MS);
Sleep(NOTE_DURATION);
} else Beep(frequencies[note - 'A'], NOTE_DURATION);
#else
# ifdef HAVE_ALSA_ASOUNDLIB_H
@ -449,7 +449,7 @@ void SudokuSound::play(char note) {
snd_pcm_prepare(handle);
snd_pcm_writei(handle, sample_data[note - 'A'], sample_size);
}
Fl::msleep(NOTE_DURATION_MS);
usleep(NOTE_DURATION*1000);
return;
}
# endif // HAVE_ALSA_ASOUNDLIB_H
@ -464,7 +464,7 @@ void SudokuSound::play(char note) {
// Sound a tone for the given note...
control.bell_percent = 100;
control.bell_pitch = frequencies[note - 'A'];
control.bell_duration = NOTE_DURATION_MS;
control.bell_duration = NOTE_DURATION;
XChangeKeyboardControl(fl_display,
KBBellPercent | KBBellPitch | KBBellDuration,