
  PROCEDURE [INLINE] nlp$cl_get_connection_tasks
    (    reference_number: nlt$cl_reference_number;
     VAR connection_found: boolean;
     VAR receiver: nlt$cl_requestor;
     VAR sender: nlt$cl_requestor);

?? PUSH (LISTEXT := ON) ??
?? RIGHT := 110 ??
*copy nlh$cl_get_connection_tasks

    VAR
      root: nlt$cl_reference_number,
      result: osc$cs_successful .. osc$cs_variable_locked,
      initial_root: nlt$cl_connection_root_access,
      new_root: nlt$cl_connection_root_access,
      actual_root: nlt$cl_connection_root_access,
      connection: ^^nlt$cl_connection;

    connection_found := FALSE;
    IF (nlv$cl_connections.list <> NIL) THEN
      initial_root.value := 0;
      new_root := initial_root;
      new_root.nonexclusive_accessors := 1;
      root := (reference_number MOD (UPPERBOUND (nlv$cl_connections.list^) + 1));

      REPEAT
        #COMPARE_SWAP (nlv$cl_connections.list^ [root].access_control, initial_root, new_root, actual_root,
              result);
        IF (result = osc$cs_successful) THEN
          connection := ^nlv$cl_connections.list^ [root].first;
          WHILE (NOT connection_found AND (connection^ <> NIL)) DO
            IF (reference_number = connection^^.identifier.reference_number) THEN
              receiver := connection^^.message_receiver;
              sender := connection^^.message_sender;
              connection_found := TRUE;
            ELSE
              connection := ^connection^^.nextt;
            IFEND;
          WHILEND;

          initial_root := new_root;
          new_root.nonexclusive_accessors := new_root.nonexclusive_accessors - 1;

        /release_root/
          REPEAT
            #COMPARE_SWAP (nlv$cl_connections.list^ [root].access_control, initial_root, new_root,
                  actual_root, result);
            IF (result = osc$cs_failed) THEN
              initial_root.nonexclusive_accessors := actual_root.nonexclusive_accessors;
              new_root.nonexclusive_accessors := initial_root.nonexclusive_accessors - 1;
            IFEND;
          UNTIL (result = osc$cs_successful);

        ELSEIF (result = osc$cs_failed) THEN
          IF NOT actual_root.exclusive THEN
            initial_root := actual_root;
            new_root := initial_root;
            new_root.nonexclusive_accessors := new_root.nonexclusive_accessors + 1;
          IFEND;
        IFEND;
      UNTIL ((result = osc$cs_successful) OR ((result = osc$cs_failed) AND actual_root.exclusive));
    IFEND;
  PROCEND nlp$cl_get_connection_tasks;
*copyc nlt$cl_connection
?? POP ??
