From 3e1da3012a2e722b3bf13217d2013a4895892a68 Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Thu, 30 Oct 2014 16:05:22 +0000 Subject: 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 --- FL/Fl.H | 10 ----- ide/VisualC2008/fltk.lib.vcproj | 46 --------------------- ide/VisualC2008/fltkdll.vcproj | 42 ------------------- ide/VisualC2010/fltk.lib.vcxproj | 3 +- ide/VisualC2010/fltk.lib.vcxproj.filters | 1 - ide/Xcode3/FLTK.xcodeproj/project.pbxproj | 4 -- ide/Xcode4/FLTK.xcodeproj/project.pbxproj | 4 -- src/CMakeLists.txt | 1 - src/Fl_sleep.cxx | 68 ------------------------------- src/Makefile | 3 +- test/sudoku.cxx | 16 ++++---- 11 files changed, 10 insertions(+), 188 deletions(-) delete mode 100644 src/Fl_sleep.cxx diff --git a/FL/Fl.H b/FL/Fl.H index b469018aa..e76a3e55f 100644 --- a/FL/Fl.H +++ b/FL/Fl.H @@ -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. diff --git a/ide/VisualC2008/fltk.lib.vcproj b/ide/VisualC2008/fltk.lib.vcproj index 7bb7899cc..4d4755d86 100644 --- a/ide/VisualC2008/fltk.lib.vcproj +++ b/ide/VisualC2008/fltk.lib.vcproj @@ -3760,52 +3760,6 @@ /> - - - - - - - - - - - - - - diff --git a/ide/VisualC2008/fltkdll.vcproj b/ide/VisualC2008/fltkdll.vcproj index 9d9a2cfc3..334aef832 100644 --- a/ide/VisualC2008/fltkdll.vcproj +++ b/ide/VisualC2008/fltkdll.vcproj @@ -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)" /> - - - - - - - - - - - - - - - Disabled @@ -2520,4 +2519,4 @@ - \ No newline at end of file + diff --git a/ide/VisualC2010/fltk.lib.vcxproj.filters b/ide/VisualC2010/fltk.lib.vcxproj.filters index e49f691a8..1259c8796 100644 --- a/ide/VisualC2010/fltk.lib.vcxproj.filters +++ b/ide/VisualC2010/fltk.lib.vcxproj.filters @@ -527,6 +527,5 @@ - diff --git a/ide/Xcode3/FLTK.xcodeproj/project.pbxproj b/ide/Xcode3/FLTK.xcodeproj/project.pbxproj index cf839e607..abf292228 100644 --- a/ide/Xcode3/FLTK.xcodeproj/project.pbxproj +++ b/ide/Xcode3/FLTK.xcodeproj/project.pbxproj @@ -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 */, ); diff --git a/ide/Xcode4/FLTK.xcodeproj/project.pbxproj b/ide/Xcode4/FLTK.xcodeproj/project.pbxproj index a988702da..c0c772a19 100644 --- a/ide/Xcode4/FLTK.xcodeproj/project.pbxproj +++ b/ide/Xcode4/FLTK.xcodeproj/project.pbxproj @@ -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 = ""; }; 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 */, diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 946f31ad2..d53ab8001 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 diff --git a/src/Fl_sleep.cxx b/src/Fl_sleep.cxx deleted file mode 100644 index fed36fdcc..000000000 --- a/src/Fl_sleep.cxx +++ /dev/null @@ -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 -#include - -#include - -#ifdef WIN32 -#include -#else -#include -#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$". -// diff --git a/src/Makefile b/src/Makefile index 3d9656c8e..3b265f9fa 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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 \ diff --git a/test/sudoku.cxx b/test/sudoku.cxx index 6eadbcb6a..5dd58724c 100644 --- a/test/sudoku.cxx +++ b/test/sudoku.cxx @@ -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 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, -- cgit v1.2.3