Duration
상속: FanObj, Literal
예제 #1
0
파일: EnvProps.cs 프로젝트: nomit007/f4
 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;
 }
예제 #2
0
파일: Time.cs 프로젝트: nomit007/f4
        //////////////////////////////////////////////////////////////////////////
        // 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);
        }
예제 #3
0
파일: ActorPool.cs 프로젝트: nomit007/f4
 internal void schedule(Actor a, Duration d, Future f)
 {
     m_scheduler.schedule(d.ticks(), new ScheduledWork(a, f));
 }
예제 #4
0
파일: ActorPool.cs 프로젝트: nomit007/f4
 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;
 }
예제 #5
0
파일: DateTime.cs 프로젝트: xored/f4
 public DateTime plus(Duration duration)
 {
     long d = duration.m_ticks;
       if (d == 0) return this;
       return makeTicks(m_ticks+d, m_tz);
 }
예제 #6
0
파일: DateTime.cs 프로젝트: xored/f4
 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);
 }
예제 #7
0
파일: DateTime.cs 프로젝트: xored/f4
        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);
        }
예제 #8
0
파일: Date.cs 프로젝트: nomit007/f4
 //////////////////////////////////////////////////////////////////////////
 // Past/Future
 //////////////////////////////////////////////////////////////////////////
 public Date plus(Duration d)
 {
     return plus(d.m_ticks);
 }
예제 #9
0
파일: Date.cs 프로젝트: nomit007/f4
 public Date minus(Duration d)
 {
     return plus(-d.m_ticks);
 }
예제 #10
0
파일: Future.cs 프로젝트: nomit007/f4
        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);
        }
예제 #11
0
 internal void schedule(Actor a, Duration d, Future f)
 {
     m_scheduler.schedule(d.ticks(), new ScheduledWork(a, f));
 }
예제 #12
0
파일: Env.cs 프로젝트: nomit007/f4
 public virtual Map props(Pod pod, Uri uri, Duration maxAge)
 {
     return m_props.get(pod, uri, maxAge);
 }