Enabling a time consuming statement via a function in uvm

I have to call the stop_sequence like below, since stop_sequence is a function, I can’t use posedge as it will be considered a time_consuming statement, is there any other I can do it without using a fork-join_none


//Sequence .
class dummy extends uvm_sequence #(REQ= packet);
bit received_item_done;
task body();
wait_for_grant();
assert(req.randomize());
send_req(req);
received_item_done = 0;
wait_for_item_done();
received_item_done = 1;
endtask
endclass


//Test

begin
fork
begin
wait(dummy_linkup == 1);
end
begin
forever
dummy.start(Sequencer);
end
join_any
@(posedge dummy.received_item_done);
disable fork;
Sequencer.stop_sequence();
end

In reply to uvm_va_1:

You should never stop a sequence. This is a bad coding style.
And you should simplify your sequence body task like this:

class dummy extends uvm_sequence #(REQ= packet);
...
task body();
  repeat(N) begin
    start_item(req);
    assert(req.randomize());
    finish_item(req);
  end
endtask
endclass

In reply to chr_sue:

okay I have to stop my sequence and I have to use the stop_sequence function, what you did is not an option

In reply to uvm_va_1:

Making things simple is always an option!!
Why are you are starting a sequence on a sequencer again and again. This makes never sense.
And where is your problem with the stop_sequences function.
You can call a function inside a task. This is not a problem.
In your test run_phase you are running a fork/join_any. One of the threads is a forever loop. It will never finish.
The other thread is stopping when received_item_done = 1;
Then you are killing the remaining process in the fork/join_any. This is the sequence process.
This kills any running sequence.