/// <summary> /// 时间事件 /// </summary> private unsafe void runTime() { DateTime now = date.Now; Monitor.Enter(timeLock); if (times.Count != 0) { fixed(DateTime *timeFixed = times.UnsafeArray) { if (*timeFixed <= now) { times.Empty(); minTime = DateTime.MaxValue; } else { DateTime *end = timeFixed + times.Count; while (*--end <= now) { ; } minTime = *end; times.UnsafeSetLength((int)(end - timeFixed) + 1); } } } Monitor.Exit(timeLock); run(); }
/// <summary> /// 设置预备服务 /// </summary> /// <param name="identity"></param> /// <param name="service"></param> internal void SetPerpService(indexIdentity identity, service service) { if (isPerpSingle || service.IsSingle) { perpServices.Empty(); perpServices.Add(new keyValue <indexIdentity, service>(identity, service)); isPerpSingle = service.IsSingle; } else { perpServices.Add(new keyValue <indexIdentity, service>(identity, service)); } }
/// <summary> /// 刷新状态验证集合 /// </summary> private static void refresh() { DateTime timeout = date.Now; Monitor.Enter(stateLock); try { foreach (KeyValuePair <ulong, DateTime> state in states) { if (state.Value <= timeout) { refreshStates.Add(state.Key); } } int count = refreshStates.Count; if (count != 0) { if (count == states.Count) { states.Clear(); } else { foreach (ulong state in refreshStates.UnsafeArray) { states.Remove(state); } } } } finally { Monitor.Exit(stateLock); refreshStates.Empty(); if (states.Count == 0) { isRefresh = 0; } else { fastCSharp.threading.timerTask.Default.Add(refreshHandle, date.NowSecond.AddMinutes(10)); } } }
/// <summary> /// 安装下一个类型 /// </summary> protected override void nextCreate() { sqlStreamMember[] members = code.memberInfo.GetMembers(type, Attribute.MemberFilter) .getArray(value => new sqlStreamMember { Member = value, Attribute = value.GetAttribute <fastCSharp.emit.dataMember>(Attribute.IsBaseTypeAttribute, Attribute.IsInheritAttribute) }); WebPaths.Empty(); list <webPathType> types; if (webPathTypes == null) { webPathTypes = new Dictionary <Type, list <webPathType> >(); foreach (Type type in AutoParameter.Types) { fastCSharp.code.cSharp.webPath webPath = type.customAttribute <fastCSharp.code.cSharp.webPath>(false); if (webPath != null && webPath.Type != null && webPath.MemberName != null) { FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public); if (fields.Length != 0) { if (!webPathTypes.TryGetValue(webPath.Type, out types)) { webPathTypes.Add(webPath.Type, types = new list <webPathType>()); } int memberIndex = fields.Length; types.Add(new webPathType { MemberType = type, Attribute = webPath, Members = fields.getArray(value => new memberInfo(value, --memberIndex)) }); } } } } if (webPathTypes.TryGetValue(type, out types)) { foreach (webPathType webPath in types) { memberInfo[] fields = webPath.CheckMembers(members); if (fields != null) { WebPaths.Add(new webPathType { MemberType = webPath.MemberType, Attribute = webPath.Attribute, Members = fields }); } } } CounterMembers = members.getFindArray(value => value.Attribute != null && value.Attribute.CounterTimeout > 0 && value.Member.Type == typeof(int)); if (Attribute.LogTcpCallService == null) { SqlStreamMembers = null; } else { SqlStreamMembers = members.getFindArray(value => value.Attribute != null && (value.Attribute.IsSqlStream || value.Attribute.SqlStreamCountType != null)); if (!Attribute.IsDefaultSerialize && Attribute.IsLogMemberMap) { fastCSharp.emit.dataSerialize dataSerialize = type.Type.customAttribute <fastCSharp.emit.dataSerialize>(true); if (dataSerialize != null && !dataSerialize.IsMemberMap) { error.Message("数据库日志流处理类型 " + type.FullName + " 序列化不支持成员位图"); } } } SqlStreamTypeCount = SqlStreamMembers.count(value => value.Attribute.SqlStreamCountType != null); subArray <sqlStreamMember> strings = members.getFind(value => value.Member.Type == typeof(string) && (value.Attribute == null || (value.Attribute.MaxStringLength == 0 && !value.Attribute.IsIgnoreMaxStringLength))); if (strings.Count != 0) { error.Message(type.FullName + " 字符串字段缺少最大长度限制 " + strings.joinString(',', value => value.Member.MemberName)); } IndexMembers = members.getFind(value => value.Attribute != null && value.Attribute.IsMemberIndex).getArray(value => value.Member); NowTimeMembers = members.getFind(value => value.Member.MemberType.IsDateTime && value.Attribute != null && value.Attribute.IsNowTime).getArray(value => new nowTimeMember { Member = value.Member }); base.nextCreate(); }