public static void do_trace(EProc proc, EAtom what, EObject info) throws Pausable { EPID pid = proc.get_trace_flags().tracer; EObject msg = ETuple4.make_tuple(am_trace, proc.self_handle(), what, info); pid.send(proc.self_handle(), msg); }
/** * @param s * @return */ public static EPID loopkup_pid(ESeq name) { String str = name.stringValue(); for (EProc p : EProc.all_tasks.values()) { if (p.self_handle().toString().equals(str)) { return p.self_handle(); } } throw ERT.badarg(name); }
private static EObject send_to_remote( EProc proc, ETuple dest, EAtom node_name, EAtom reg_name, EObject msg, EObject options) throws Pausable { // INVARIANT: t == ETuple.make(node_name, reg_name) if (node_name == getLocalNode().node) { // We're talking to ourselves send_to_locally_registered(proc, reg_name, msg); return am_ok; // Even if the process does not exist. // TODO: Return 'noconnect' if options contain noconnect?... } else { // We're talking to another node if (ipclog.isLoggable(Level.FINE)) { ipclog.fine("sending msg " + dest + " ! " + msg); } EAbstractNode node = EPeer.get(node_name); if (node == null) { EObject[] args = (options != null ? new EObject[] {dest, msg, options} : new EObject[] {dest, msg, ERT.NIL}); return erlang__dsend__3.invoke(proc, args); } else { node.dsig_reg_send(proc.self_handle(), reg_name, msg); return am_ok; } } }
@BIF public static EInteger trace_pattern(EProc proc, EObject arg0, EObject arg1, EObject arg2) { ETuple3 mfa = ETuple3.cast(arg0); EAtom mod, fun; if (mfa == null || (mod = mfa.elem1.testAtom()) == null || (fun = mfa.elem2.testAtom()) == null) { throw ERT.badarg(arg0, arg1, arg2); } int count = EModuleManager.trace_pattern(proc.self_handle(), mod, fun, mfa.elem3, arg1, arg2); return ERT.box(count); }
@BIF public static EInteger trace(EProc self_proc, EObject arg0, EObject arg1, EObject arg2) { EInternalPID pid = arg0.testInternalPID(); EAtom all = arg0.testAtom(); EObject how = arg1.testBoolean(); ESeq flags = arg2.testSeq(); if ((pid == null && all != am_all) || how == null || flags == null) { throw ERT.badarg(arg0, arg1, arg2); } EInternalPID self = self_proc.self_handle(); if (all == am_all) { ESeq allprocs = EProc.processes(); int result = allprocs.length(); global_trace_flags.update(how == ERT.TRUE, flags, self); while (!allprocs.isNil()) { EProc proc = allprocs.head().testInternalPID().task(); allprocs = allprocs.tail(); if (proc.trace_flags != null) { proc.trace_flags.update(how == ERT.TRUE, flags, self); } } return ERT.box(result); } else { EProc proc = pid.task(); if (!proc.is_alive_dirtyread()) { return ESmall.ZERO; } if (proc.trace_flags == null) { proc.trace_flags = global_trace_flags.clone(); } proc.trace_flags.update(how == ERT.TRUE, flags, self); return ESmall.ONE; } }
private static void send_to_handle(EProc proc, EHandle handle, EObject msg) throws Pausable { int penalty = handle.send(proc.self_handle(), msg); proc.bump_reductions(penalty); }