anchor.diff:    end;
   
   handle_call(pop, _From, #state{mem=Mem} = State) ->
  -  case pop_and_purge(Mem) of
  -    nil ->
  -      %% Empty queue
  -      {reply, nil, State};
  -    Msg ->
  -      {reply, Msg, State}
  +  Msg = pop_and_purge(Mem),
  +  {reply, Msg, State};
  +
  +handle_call(peek, _From, #state{mem=Mem} = State) ->
  +  Msg = peek(Mem),
  +  {reply, Msg, State};
  +
  +handle_call({try_pop, Fun}, _From, #state{mem=Mem} = State) ->
  +  try
  +    {reply, {ok, try_pop_and_purge(Mem, Fun)}, State}
  +  catch _:E:ST ->
  +    {reply, {error, E, ST}, State}
     end;
   
   handle_call(info, _From, #state{mem=Mem} = State) ->
  
positive.code: %%%-----------------------------------------------------------------------------
  -module(emmap_queue).
  -export([open/3, close/1]).
  -export([purge_queue/1, is_empty/1, length/1, push/2, pop/1, pop_and_purge/1]).
  
  -export([start_link/4, init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2]).
  -export([enqueue/2, dequeue/1, info/1]).
  
  -compile({no_auto_import,[length/1]}).
  
  
negative.code:   , segm_sz  :: non_neg_integer()
  }).
  
  -define(TIMEOUT, infinity).
  
  %%------------------------------------------------------------------------------
  %% Gen_server API
  %%------------------------------------------------------------------------------
  
  %% @doc Start a queue process.
  %% `Name' - name of the registered process.
  %% `Filename' - name of the memory mapped file.
  %% `SegmSize' - size of the memory mapped segment (can be 0 for an existing file).
  %% `Opts' - see `emmap:open_options()'.
  start_link(Name, Filename, SegmSize, Opts) when is_list(Opts) ->
    gen_server:start_link({local, Name}, ?MODULE, [Filename, SegmSize, Opts], []).
  
  %% @doc Enqueue a message to the queue
  enqueue(Name, Term) ->
    gen_server:call(Name, {push, Term}, ?TIMEOUT).
  
  %% @doc Dequeue a message from the queue
  dequeue(Name) ->
    gen_server:call(Name, pop, ?TIMEOUT).
  
  %% @doc Dequeue a message from the queue.
  %% The function returns `Res' where `Res' is the result of evaluating
  %% the `Fun' with the poped element from the queue.  If the `Fun' throws an
  %% exception, the exception if propagated to the caller.
  try_dequeue(Name, Fun) when is_function(Fun, 1) ->
    case gen_server:call(Name, {try_pop, Fun}, ?TIMEOUT) of
      {ok, Res} ->
        Res;
      {error, Error, Stacktrace} ->
        erlang:error(Error, Stacktrace)
    end.
  
  %% @doc Peek a message from the queue without dequeuing it
  inspect(Name) ->
    gen_server:call(Name, peek, ?TIMEOUT).
  
  %% @doc Return queue info as a map
  -spec info(atom()) -> map().
  info(Name) ->
    gen_server:call(Name, info, ?TIMEOUT).
  
  %%------------------------------------------------------------------------------
  %% Gen_server callbacks
  