/[dtapublic]/to_be_filed/webprojs/php_libraries/php_library/general/puts.inc
ViewVC logotype

Contents of /to_be_filed/webprojs/php_libraries/php_library/general/puts.inc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 35 - (show annotations) (download)
Sat Oct 8 23:35:33 2016 UTC (7 years, 8 months ago) by dashley
File size: 2776 byte(s)
Initial commit.
1 <?php
2 if (!isset($GENERAL_TIMERAW_INCLUDED))
3 {
4 include("general/timeraw.inc");
5 $GENERAL_TIMERAW_INCLUDED=1;
6 }
7 ?>
8 <?php
9 //********************************************************************************
10 //Copyright (C) 2006 David T. Ashley
11 //********************************************************************************
12 //This program or source file is free software; you can redistribute it and/or
13 //modify it under the terms of the GNU General Public License as published by
14 //the Free Software Foundation; either version 2 of the License, or (at your
15 //option) any later version.
16 //
17 //This program or source file is distributed in the hope that it will
18 //be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
19 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 //GNU General Public License for more details.
21 //
22 //You may have received a copy of the GNU General Public License
23 //along with this program; if not, write to the Free Software
24 //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 //********************************************************************************
26 //Dave Ashley, 01/06
27 //
28 //This source file provides the code to create process-unique
29 //timestamps. A process-unique timestamp is guaranteed to be unique
30 //because this code will spin-lock until the time changes.
31 //
32 //A process-unique timestamp is 72 bits of information (18 hexadecimal
33 //digits). The breakdown is:
34 //
35 // a)First 40 bits (10 hexadecimal digits). The integer time, in seconds
36 // since the Unix epoch. The extra 8 bits are reserved due to the impending
37 // Unix 2037 AD issue.
38 //
39 // b)Second 32 bits (8 hexadecimal digits). The nanoseconds representing the
40 // fractional part of the integer seconds.
41 //
42 //Note that both of the data sizes above are designed to allow future
43 //expansion. The integer part is designed for the Unix 2037 issue. The
44 //fractional part is designed for faster hardware in the future.
45 //
46 //
47 function PUTS_timestamp()
48 {
49 //Obtain the initial value.
50 $rv = TIMERAW_time_precision_hex();
51
52 //Wait for the time to change. Although I don't think it would make a difference
53 //in practice, there is sleep to be more efficient.
54 $new_time = TIMERAW_time_precision_hex();
55 if ($rv == $new_time)
56 {
57 do
58 {
59 usleep(100);
60 $new_time = TIMERAW_time_precision_hex();
61 }
62 while ($rv == $new_time);
63 }
64
65 //The time has changed. We are clear to return.
66 return($rv);
67 }
68 //
69 //
70 //Returns the size (in chars) of a process-unique timestamp.
71 //
72 function PUTS_timestamp_size()
73 {
74 return(TIMERAW_time_precision_hex_size());
75 }
76 ?>

dashley@gmail.com
ViewVC Help
Powered by ViewVC 1.1.25