public Map get(Pod pod, Uri uri, Duration maxAge) { Key key = new Key(pod, uri); CachedProps cp = (CachedProps)m_cache[key]; if (cp == null || Duration.nowTicks() - cp.m_read > maxAge.m_ticks) cp = refresh(key, cp); return cp.m_props; }
////////////////////////////////////////////////////////////////////////// // Misc ////////////////////////////////////////////////////////////////////////// public static Time fromDuration(Duration d) { long ticks = d.m_ticks; if (ticks == 0) return m_defVal; if (ticks < 0 || ticks > Duration.nsPerDay ) throw ArgErr.make("Duration out of range: " + d).val; int hour = (int)(ticks / Duration.nsPerHr); ticks %= Duration.nsPerHr; int min = (int)(ticks / Duration.nsPerMin); ticks %= Duration.nsPerMin; int sec = (int)(ticks / Duration.nsPerSec); ticks %= Duration.nsPerSec; int ns = (int)ticks; return new Time(hour, min, sec, ns); }
internal void schedule(Actor a, Duration d, Future f) { m_scheduler.schedule(d.ticks(), new ScheduledWork(a, f)); }
public ActorPool join(Duration timeout) { if (!isStopped()) throw Err.make("ActorPool is not stopped").val; long ms = timeout == null ? System.Int32.MaxValue : timeout.millis(); try { if (m_threadPool.join(ms)) return this; } catch (System.Threading.ThreadInterruptedException e) { throw InterruptedErr.make(e).val; } throw TimeoutErr.make("ActorPool.join timed out").val; }
public DateTime plus(Duration duration) { long d = duration.m_ticks; if (d == 0) return this; return makeTicks(m_ticks+d, m_tz); }
public DateTime floor(Duration accuracy) { if (m_ticks % accuracy.m_ticks == 0) return this; return makeTicks(m_ticks - (m_ticks % accuracy.m_ticks), m_tz); }
public static DateTime nowUtc(Duration tolerance) { long now = (System.DateTime.Now.Ticks - diffDotnet) * nsPerTick; DateTime c = cachedUtc; if (tolerance != null && now - c.m_ticks <= tolerance.m_ticks) return c; return cachedUtc = new DateTime(now, TimeZone.m_utc); }
////////////////////////////////////////////////////////////////////////// // Past/Future ////////////////////////////////////////////////////////////////////////// public Date plus(Duration d) { return plus(d.m_ticks); }
public Date minus(Duration d) { return plus(-d.m_ticks); }
public object get(Duration timeout) { object r = null; try { lock (this) { // wait until we enter a done state, the only notifies // on this object should be from cancel, set, or err if (timeout == null) { // wait forever until done while ((m_state & DONE) == 0) Monitor.Wait(this); } else { // if not done, then wait with timeout and then // if still not done throw a timeout exception if ((m_state & DONE) == 0) { Monitor.Wait(this, (int)timeout.millis()); if ((m_state & DONE) == 0) throw TimeoutErr.make("Future.get timed out").val; } } // if canceled throw CancelErr if (m_state == DONE_CANCEL) throw CancelledErr.make("message canceled").val; // if error was raised, raise it to caller if (m_state == DONE_ERR) throw ((Err)m_result).rebase(); // assign result to local variable for return r = m_result; } } catch (ThreadInterruptedException e) { throw InterruptedErr.make(e).val; } // ensure immutable or safe copy return Sys.safe(r); }
public virtual Map props(Pod pod, Uri uri, Duration maxAge) { return m_props.get(pod, uri, maxAge); }