Can We have a run_phase method in subscriber file?

class my_subscriber extends uvm_subscriber #(packet);
`uvm_component_utils(my_subscriber)

task run_phase (uvm_phase phase)
// is this possible
endtask

endclass

If anyone could provide a suitable example ??

Any class extended from uvm_component, including uvm_subscriber, can have any of the phase based functions or tasks.

Typically, a subscriber is reactive to transactions sent to it and does not require its own thread.

In reply to dave_59:

Thanks Dave for the answer.
In this case I have a particular requirement where my cover groups are active on a clock and the write method used to update the subscriber local variables is called from the monitor at the same clock.
To ensure the write method is called before the cover groups are evaluated I need to generate an internal clock for the subscriber for which I need the run_phase.
Do you have an alternate solution to this ? Please provide an example if applicable.

Why not use the write method inside the subscriber to dispath an event and than trigger the coverage group by this event ? You could place the “->event” wherever it better fits inside the “write”.

In reply to fcunha:

Or just have the write() method of the subscriber call the sample method of the covergroup.