1 ' OpenTween - Client of Twitter
2 ' Copyright (c) 2011 kiri_feather (@kiri_feather) <kiri.feather@gmail.com>
3 ' (c) 2011 fantasticswallow (@f_swallow) <http://twitter.com/f_swallow>
6 ' This file is part of OpenTween.
8 ' This program is free software; you can redistribute it and/or modify it
9 ' under the terms of the GNU General Public License as published by the Free
10 ' Software Foundation; either version 3 of the License, or (at your option)
13 ' This program is distributed in the hope that it will be useful, but
14 ' WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
15 ' or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18 ' You should have received a copy of the GNU General Public License along
19 ' with this program. If not, see <http://www.gnu.org/licenses/>, or write to
20 ' the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
21 ' Boston, MA 02110-1301, USA.
23 Imports System.Threading.Tasks
26 Public Class FavoriteQueue
27 Implements IList(Of Long)
29 'Private Shared _instance As New FavoriteQueue
30 'Public Shared ReadOnly Property GetInstance As FavoriteQueue
37 Private FavoriteCache As New List(Of Long)
39 Public Sub AddRange(ByVal stsIds As IEnumerable(Of Long))
40 FavoriteCache.AddRange(stsIds)
43 'Public Sub FavoriteCacheAdd(ByVal statusId As Long, ByVal res As HttpStatusCode, Optional ByRef isMsg As Boolean = True)
44 ' 'If Not SettingInfo.Instance.IsUseFavoriteQueue Then Exit Sub
46 ' Case HttpStatusCode.BadGateway, HttpStatusCode.BadRequest, HttpStatusCode.ServiceUnavailable, HttpStatusCode.InternalServerError, HttpStatusCode.RequestTimeout
48 ' FavoriteCache.Add(statusId)
52 Public Sub FavoriteCacheStart()
53 If Not FavoriteCache.Count = 0 Then
54 Dim _cacheList As New List(Of Long)(FavoriteCache)
56 Parallel.ForEach(Of Long)(_cacheList, New Action(Of Long)(Sub(stsId As Long)
62 Public Sub Add(ByVal item As Long) Implements System.Collections.Generic.ICollection(Of Long).Add
63 If Not Me.Contains(item) Then
64 FavoriteCache.Add(item)
68 Public Sub Clear() Implements System.Collections.Generic.ICollection(Of Long).Clear
70 FavoriteCache.TrimExcess()
73 Public Function Contains(ByVal item As Long) As Boolean Implements System.Collections.Generic.ICollection(Of Long).Contains
74 FavoriteCache.Contains(item)
77 Public Sub CopyTo(ByVal array() As Long, ByVal arrayIndex As Integer) Implements System.Collections.Generic.ICollection(Of Long).CopyTo
78 FavoriteCache.CopyTo(array, arrayIndex)
81 Public ReadOnly Property Count As Integer Implements System.Collections.Generic.ICollection(Of Long).Count
83 Return FavoriteCache.Count
87 Public ReadOnly Property IsReadOnly As Boolean Implements System.Collections.Generic.ICollection(Of Long).IsReadOnly
93 Public Function Remove(ByVal item As Long) As Boolean Implements System.Collections.Generic.ICollection(Of Long).Remove
94 Return FavoriteCache.Remove(item)
97 Public Function GetEnumerator() As System.Collections.Generic.IEnumerator(Of Long) Implements System.Collections.Generic.IEnumerable(Of Long).GetEnumerator
98 Return FavoriteCache.GetEnumerator()
100 Public Function GetEnumerator1() As System.Collections.IEnumerator Implements System.Collections.IEnumerable.GetEnumerator
101 Return Me.GetEnumerator
104 Public Function IndexOf(ByVal item As Long) As Integer Implements System.Collections.Generic.IList(Of Long).IndexOf
105 Return FavoriteCache.IndexOf(item)
108 Public Sub Insert(ByVal index As Integer, ByVal item As Long) Implements System.Collections.Generic.IList(Of Long).Insert
109 FavoriteCache.Insert(index, item)
112 Default Public Property Item(ByVal index As Integer) As Long Implements System.Collections.Generic.IList(Of Long).Item
114 Return FavoriteCache(index)
116 Set(ByVal value As Long)
117 FavoriteCache(index) = value
121 Public Sub RemoveAt(ByVal index As Integer) Implements System.Collections.Generic.IList(Of Long).RemoveAt
122 FavoriteCache.RemoveAt(index)
125 Public Sub New(ByVal twitter As Twitter)