anchor.diff:  
      receive
         { close,PID } ->
  -         PID ! { closed,{channel,ID} },
  -         closed;
  +         case State#state.state of 
  +            idle ->
  +               PID ! { closed,{channel,ID} };
  +
  +            { write_pending,{_Word,WRITER}} ->
  +               WRITER ! { closed,{channel,ID} },
  +               PID    ! { closed,{channel,ID} };
  +
  +            {read_pending,READER} ->
  +               READER ! { closed,{channel,ID} },
  +               PID    ! { closed,{channel,ID} }
  +            end;
   
         { write,Word,WRITER } ->
            case State#state.state of 
  
positive.code: write_then_read_test() ->
     Channel = create(666),
     M       = self(),
     spawn(fun() ->                   M ! { write,write(Channel,123) } end),
     spawn(fun() -> timer:sleep(500), M ! { read, read (Channel)     } end),
     ?assertEqual({ok,{ok,123}},wait(undefined,undefined)),
     ?assertEqual(closed,close(Channel)).
  
  read_then_write_test() ->
     Channel = create(666),
     M       = self(),
     spawn(fun() ->                   M ! { read, read (Channel)     } end),
     spawn(fun() -> timer:sleep(500), M ! { write,write(Channel,123) } end),
     ?assertEqual({ok,{ok,123}},wait(undefined,undefined)),
     ?assertEqual(closed,close(Channel)).
   
  wait({write,W},{read,R}) ->
     {W,R};
   
  wait(W,R) ->
     receive 
        { read,RV } ->
           wait(W,{read,RV});
  
        { write,WV } ->
           wait({write,WV},R);
  
        _any ->
           wait(W,R)
     end.
  
  
negative.code:       { read,{channel,ID},Word } ->
           { ok,Word };
  
        { closed,{channel,ID} } ->
           closed;
  
     _any ->
        read_wait(ID,Timeout)
  
  