From dc8e62f33ad0ca7a772ec74d67b6d3e157f639b4 Mon Sep 17 00:00:00 2001 From: Rickard Green Date: Wed, 13 Jan 2016 18:33:42 +0100 Subject: Introduce time warp safe replacement for safe_fixed option The new time warp safe option is safe_fixed_monotonic_time which gives erlang:monotonic_time(). The safe_fixed option was also slightly changed. It now gives erlang:timestamp() instead of erlang:now(). This has however not been documented, so it is considered a compatible change. The above effects both ets, and dets. This commit also include the bugfix OTP-13239 for dets:info(Tab, safe_fixed). The timestamp in the result returned by dets:info(Tab, safe_fixed) was unintentionally broken as a result of the time API rewrites in OTP 18.0. --- lib/stdlib/doc/src/dets.xml | 31 ++++++++++++++++++++++++++++--- lib/stdlib/doc/src/ets.xml | 41 ++++++++++++++++++++++++++++++++++------- 2 files changed, 62 insertions(+), 10 deletions(-) (limited to 'lib/stdlib/doc/src') diff --git a/lib/stdlib/doc/src/dets.xml b/lib/stdlib/doc/src/dets.xml index a0d3f95b6a..48400733d1 100644 --- a/lib/stdlib/doc/src/dets.xml +++ b/lib/stdlib/doc/src/dets.xml @@ -399,15 +399,40 @@ kept in RAM.

-

{safe_fixed, SafeFixed}. If the table - is fixed, SafeFixed is a tuple {FixedAtTime, [{Pid,RefCount}]}. FixedAtTime is the time when +

{safe_fixed_monotonic_time, SafeFixed}. If the table + is fixed, SafeFixed is a tuple {FixedAtTime, [{Pid,RefCount}]}. + FixedAtTime is the time when the table was first fixed, and Pid is the pid of the process that fixes the table RefCount times. There may be any number of processes in the list. If the table is not fixed, SafeFixed is the atom false.

+

FixedAtTime will correspond to the result + returned by + erlang:monotonic_time/0 + at the time of fixation. The usage of safe_fixed_monotonic_time is + time warp + safe.

-

{version, integer(), the version of the format of +

+ {safe_fixed, SafeFixed}. The same as + {safe_fixed_monotonic_time, SafeFixed} with the exception + of the format and value of FixedAtTime. +

+

+ FixedAtTime will correspond to the result returned by + erlang:timestamp/0 + at the time of fixation. Note that when the system is using + single or multi + time warp + modes this might produce strange results. This + since the usage of safe_fixed is not + time warp + safe. Time warp safe code need to use + safe_fixed_monotonic_time instead.

+
+ +

{version, integer()}, the version of the format of the table.

diff --git a/lib/stdlib/doc/src/ets.xml b/lib/stdlib/doc/src/ets.xml index 7b01109ff8..447fe51130 100644 --- a/lib/stdlib/doc/src/ets.xml +++ b/lib/stdlib/doc/src/ets.xml @@ -488,14 +488,39 @@ Error: fun containing local Erlang function calls Item=fixed, Value=boolean()

Indicates if the table is fixed by any process or not.
- -

Item=safe_fixed, Value={FirstFixed,Info}|false

+ +

Item=safe_fixed|safe_fixed_monotonic_time, Value={FixationTime,Info}|false

-

If the table has been fixed using safe_fixtable/2, - the call returns a tuple where FirstFixed is the +

If the table has been fixed using + safe_fixtable/2, + the call returns a tuple where FixationTime is the time when the table was first fixed by a process, which may or may not be one of the processes it is fixed by right now.

+

The format and value of FixationTime depends on + Item:

+ + safe_fixed +

FixationTime will correspond to the result + returned by + erlang:timestamp/0 + at the time of fixation. Note that when the system is using + single or multi + time warp + modes this might produce strange results. This + since the usage of safe_fixed is not + time warp + safe. Time warp safe code need to use + safe_fixed_monotonic_time instead.

+ + safe_fixed_monotonic_time +

FixationTime will correspond to the result + returned by + erlang:monotonic_time/0 + at the time of fixation. The usage of safe_fixed_monotonic_time is + time warp + safe.

+

Info is a possibly empty lists of tuples {Pid,RefCount}, one tuple for every process the table is fixed by right now. RefCount is the value @@ -1135,9 +1160,11 @@ clean_all_with_value(Tab,X,Key) -> table but never releases it, the memory used by the deleted objects will never be freed. The performance of operations on the table will also degrade significantly.

-

Use info/2 to retrieve information about which - processes have fixed which tables. A system with a lot of - processes fixing tables may need a monitor which sends alarms +

Use + info(Tab, + safe_fixed_monotonic_time) to retrieve information + about which processes have fixed which tables. A system with a lot + of processes fixing tables may need a monitor which sends alarms when tables have been fixed for too long.

Note that for tables of the ordered_set type, safe_fixtable/2 is not necessary as calls to -- cgit v1.2.3