예제 #1
0
        internal unsafe void SendMissReport(IFontCacheElement e)
        {
            //If we are not connected to the server, there's no one to send the miss report to, so don't.
            if (_conn == null)
            {
                return;
            }

            byte[] request = new byte[Math.Min(MaxMissReportSize, _conn.GetMaxRequestBytes())];

            //If the connection cannot support a long enough request to hold the message type and element type,
            //we can't send the miss report.
            if (request.Length < 2 * sizeof(int))
                return;

            fixed(byte *ptr = &request[0])
            {
                //Store the message type
                ((int *)ptr)[0] = FontCacheConstants.SendMissReportMessage;

                //Store the element type
                ((int *)ptr)[1] = e.Type;

                //Store the key information
                CheckedPointer key = new CheckedPointer(ptr, request.Length);

                key += 2 * sizeof(int);
                try
                {
                    int realSize = 0;
                    e.StoreKey(key, out realSize);
                    Debug.Assert(realSize >= 0, "realSize is negative");
                    // realSize will be zero for non-shareable elements like in-memory fonts
                    if (realSize != 0)
                    {
                        realSize += 2 * sizeof(int);//adjust for message header and miss report header
                        Debug.Assert(realSize <= request.Length, "realSize too large");

                        //Send the request as a datagram (ignore error code)
                        int errorCode = 0;
                        _protocol.TrySendRequest(_conn, request, 0, realSize, null, 0, 0, 0, out errorCode);
                    }
                }
                catch (ArgumentOutOfRangeException)
                {
                    // the key didn't fit into the buffer, just don't send the miss report
                    return;
                }
            }
        }
예제 #2
0
        internal static void Lookup(IFontCacheElement e)
        {
            ElementCacher c;

            if (!e.IsAppSpecific)
            {
                c = GetServerCache();
                if (c != null)
                {
                    if (c.ReadOnlyLookup(e))
                    {
                        return;
                    }

                    EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordText, EventTrace.Event.WClientFontCache);
                }
                else
                {
                    EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordText, EventTrace.Event.WClientFontCache);
                }
            }

            c = GetCurrentCache();

            for (; ;)
            {
                try
                {
                    if (!c.LookupAndAdd(e) && !e.IsAppSpecific)
                    {
                        // send a miss report if we had to add a new element
                        SendMissReport(e);
                    }
                    return;
                }
                catch (FontCacheFullException)
                {
                    EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordText, EventTrace.Event.WClientFontCache);
                }

                // Cache overflow, start a new cache and attempt element construction again.
                c = RenewCache(c);
            }
        }
예제 #3
0
 internal bool ReadOnlyLookup(IFontCacheElement e)
 {
     return(_hashTable.Lookup(e, false));
 }
예제 #4
0
 internal static void SendMissReport(IFontCacheElement e)
 {
     Debug.Assert(!e.IsAppSpecific);
     _ipcMngr.SendMissReport(e);
 }
예제 #5
0
 internal bool LookupAndAdd(IFontCacheElement e)
 {
     return(_hashTable.Lookup(e, true));
 }