Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix concurrency contention when recording high water mark in ets_buffer #27

Merged
merged 1 commit into from

1 participant

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 11 additions and 11 deletions.
  1. +11 −11 src/ets_buffer.erl
View
22 src/ets_buffer.erl
@@ -596,25 +596,25 @@ write_internal(Table_Name, Buffer_Name, Data) ->
case buffer_type(Type_Num) of
%% FIFO continuously increments...
- fifo -> Write_Loc = ets:update_counter(Table_Name, Meta_Key, fifo_reserve_write_cmd()),
- true = insert_ets_internal(Table_Name, Buffer_Name, Write_Loc, Data),
- [Write_Loc, Read_Loc] = ets:update_counter(Table_Name, Meta_Key, fifo_publish_write_cmd()),
- Num_Entries = compute_num_entries(Type_Num, Max_Loc, Write_Loc, Read_Loc),
+ fifo -> Reserved_Loc = ets:update_counter(Table_Name, Meta_Key, fifo_reserve_write_cmd()),
+ true = insert_ets_internal(Table_Name, Buffer_Name, Reserved_Loc, Data),
+ [New_Write_Loc, Read_Loc] = ets:update_counter(Table_Name, Meta_Key, fifo_publish_write_cmd()),
+ Num_Entries = compute_num_entries(Type_Num, Max_Loc, New_Write_Loc, Read_Loc),
Num_Entries > High_Water_Count andalso set_high_water(Table_Name, Meta_Key, Num_Entries),
Num_Entries;
%% Ring buffer wraps around on inserts...
- ring -> [Write_Loc, Read_Loc] = ets:update_counter(Table_Name, Meta_Key, ring_reserve_write_cmd(Max_Loc)),
- true = insert_ets_internal(Table_Name, Buffer_Name, Write_Loc, Data),
- [Write_Loc, Read_Loc] = ets:update_counter(Table_Name, Meta_Key, ring_publish_write_cmd(Max_Loc, Write_Loc, Read_Loc)),
- Num_Entries = compute_num_entries(Type_Num, Max_Loc, Write_Loc, Read_Loc),
+ ring -> [Reserved_Loc, Read_Loc] = ets:update_counter(Table_Name, Meta_Key, ring_reserve_write_cmd(Max_Loc)),
+ true = insert_ets_internal(Table_Name, Buffer_Name, Reserved_Loc, Data),
+ [New_Write_Loc, New_Read_Loc] = ets:update_counter(Table_Name, Meta_Key, ring_publish_write_cmd(Max_Loc, Reserved_Loc, Read_Loc)),
+ Num_Entries = compute_num_entries(Type_Num, Max_Loc, New_Write_Loc, New_Read_Loc),
Num_Entries > High_Water_Count andalso set_high_water(Table_Name, Meta_Key, Num_Entries),
Num_Entries;
%% LIFO continuously decrements...
- lifo -> Write_Loc = ets:update_counter(Table_Name, Meta_Key, lifo_reserve_write_cmd()),
- true = insert_ets_internal(Table_Name, Buffer_Name, Write_Loc, Data),
- _ = ets:update_counter(Table_Name, Meta_Key, lifo_publish_write_cmd(Write_Loc)),
+ lifo -> Reserved_Loc = ets:update_counter(Table_Name, Meta_Key, lifo_reserve_write_cmd()),
+ true = insert_ets_internal(Table_Name, Buffer_Name, Reserved_Loc, Data),
+ _ = ets:update_counter(Table_Name, Meta_Key, lifo_publish_write_cmd(Reserved_Loc)),
%% High water mark not possible with current LIFO approach
true
end
Something went wrong with that request. Please try again.