Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
M
Mirai
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Mirai
Commits
c3de96dd
Commit
c3de96dd
authored
Apr 27, 2020
by
Him188
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mark LockFreeLinkedList with MiraiInternalAPI, planning to make it internal in 1.0.0
parent
a0f39e61
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
0 deletions
+22
-0
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/ContactList.kt
.../commonMain/kotlin/net.mamoe.mirai/contact/ContactList.kt
+4
-0
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/internal/InternalEventListeners.kt
.../net.mamoe.mirai/event/internal/InternalEventListeners.kt
+2
-0
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/CustomMessage.kt
...Main/kotlin/net.mamoe.mirai/message/data/CustomMessage.kt
+3
-0
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/LockFreeLinkedList.kt
...onMain/kotlin/net.mamoe.mirai/utils/LockFreeLinkedList.kt
+10
-0
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/event/internal/MiraiAtomicBoolean.kt
...tlin/net/mamoe/mirai/event/internal/MiraiAtomicBoolean.kt
+3
-0
No files found.
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/contact/ContactList.kt
View file @
c3de96dd
...
...
@@ -81,16 +81,19 @@ val ContactList<*>.idContentString: String
)
+
"]"
@MiraiInternalAPI
operator
fun
<
C
:
Contact
>
LockFreeLinkedList
<
C
>.
get
(
id
:
Long
):
C
{
forEach
{
if
(
it
.
id
==
id
)
return
it
}
throw
NoSuchElementException
(
"No such contact: $id"
)
}
@MiraiInternalAPI
fun
<
C
:
Contact
>
LockFreeLinkedList
<
C
>.
getOrNull
(
id
:
Long
):
C
?
{
forEach
{
if
(
it
.
id
==
id
)
return
it
}
return
null
}
@OptIn
(
MiraiInternalAPI
::
class
)
@PlannedRemoval
(
"1.0.0"
)
@Deprecated
(
"use firstOrNull from stdlib"
,
...
...
@@ -102,6 +105,7 @@ inline fun <C : Contact> LockFreeLinkedList<C>.firstOrNull(filter: (C) -> Boolea
return
null
}
@OptIn
(
MiraiInternalAPI
::
class
)
@PlannedRemoval
(
"1.0.0"
)
@Deprecated
(
"use firstOrNull from stdlib"
,
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/event/internal/InternalEventListeners.kt
View file @
c3de96dd
...
...
@@ -6,6 +6,7 @@
*
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
@
file
:
OptIn
(
MiraiInternalAPI
::
class
)
package
net.mamoe.mirai.event.internal
...
...
@@ -122,6 +123,7 @@ internal object EventListenerManager {
// 不要用 atomicfu. 在 publish 后会出现 VerifyError
private
val
lock
:
MiraiAtomicBoolean
=
MiraiAtomicBoolean
(
false
)
@OptIn
(
MiraiInternalAPI
::
class
)
@Suppress
(
"UNCHECKED_CAST"
,
"BooleanLiteralArgument"
)
internal
tailrec
fun
<
E
:
Event
>
get
(
clazz
:
KClass
<
out
E
>):
EventListeners
<
E
>
{
registries
.
forEach
{
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/message/data/CustomMessage.kt
View file @
c3de96dd
...
...
@@ -7,6 +7,7 @@
* https://github.com/mamoe/mirai/blob/master/LICENSE
*/
@
file
:
OptIn
(
MiraiInternalAPI
::
class
)
package
net.mamoe.mirai.message.data
import
kotlinx.io.core.*
...
...
@@ -114,6 +115,7 @@ sealed class CustomMessage : SingleMessage {
override
val
typeName
:
String
get
()
=
"CustomMessage"
private
val
factories
:
LockFreeLinkedList
<
Factory
<
*
>>
=
LockFreeLinkedList
()
@OptIn
(
MiraiInternalAPI
::
class
)
internal
fun
register
(
factory
:
Factory
<
out
CustomMessage
>)
{
factories
.
removeIf
{
it
::
class
== factory::class }
val exist = factories.as
Sequence
().
firstOrNull
{
it
.
typeName
==
factory
.
typeName
}
...
...
@@ -134,6 +136,7 @@ sealed class CustomMessage : SingleMessage {
class
CustomMessageFullDataDeserializeUserException
(
val
body
:
ByteArray
,
cause
:
Throwable
?)
:
RuntimeException
(
cause
)
@OptIn
(
MiraiInternalAPI
::
class
)
internal
fun
deserialize
(
fullData
:
ByteReadPacket
):
CustomMessage
?
{
val
msg
=
kotlin
.
runCatching
{
val
length
=
fullData
.
readInt
()
...
...
mirai-core/src/commonMain/kotlin/net.mamoe.mirai/utils/LockFreeLinkedList.kt
View file @
c3de96dd
...
...
@@ -19,11 +19,13 @@ import kotlin.jvm.JvmOverloads
/**
* Collect all the elements into a [MutableList] then cast it as a [List]
*/
@MiraiInternalAPI
fun
<
E
>
LockFreeLinkedList
<
E
>.
toList
():
List
<
E
>
=
toMutableList
()
/**
* Collect all the elements into a [MutableList].
*/
@MiraiInternalAPI
fun
<
E
>
LockFreeLinkedList
<
E
>.
toMutableList
():
MutableList
<
E
>
{
val
list
=
mutableListOf
<
E
>()
this
.
forEach
{
list
.
add
(
it
)
}
...
...
@@ -33,11 +35,13 @@ fun <E> LockFreeLinkedList<E>.toMutableList(): MutableList<E> {
/**
* Collect all the elements into a [MutableSet] then cast it as a [Set]
*/
@MiraiInternalAPI
fun
<
E
>
LockFreeLinkedList
<
E
>.
toSet
():
Set
<
E
>
=
toMutableSet
()
/**
* Collect all the elements into a [MutableSet].
*/
@MiraiInternalAPI
fun
<
E
>
LockFreeLinkedList
<
E
>.
toMutableSet
():
MutableSet
<
E
>
{
val
list
=
mutableSetOf
<
E
>()
this
.
forEach
{
list
.
add
(
it
)
}
...
...
@@ -49,6 +53,7 @@ fun <E> LockFreeLinkedList<E>.toMutableSet(): MutableSet<E> {
*
* Note that the sequence is dynamic, that is, elements are yielded atomically only when it is required
*/
@MiraiInternalAPI
fun
<
E
>
LockFreeLinkedList
<
E
>.
asSequence
():
Sequence
<
E
>
{
return
sequence
{
forEach
{
...
...
@@ -57,6 +62,7 @@ fun <E> LockFreeLinkedList<E>.asSequence(): Sequence<E> {
}
}
@MiraiInternalAPI
operator
fun
<
E
>
LockFreeLinkedList
<
E
>.
iterator
():
Iterator
<
E
>
{
return
asSequence
().
iterator
()
}
...
...
@@ -64,6 +70,7 @@ operator fun <E> LockFreeLinkedList<E>.iterator(): Iterator<E> {
/**
* 构建链表结构然后转为 [LockFreeLinkedList]
*/
@MiraiInternalAPI
fun
<
E
>
Iterable
<
E
>.
toLockFreeLinkedList
():
LockFreeLinkedList
<
E
>
{
return
LockFreeLinkedList
<
E
>().
apply
{
addAll
(
this
@
toLockFreeLinkedList
)
}
}
...
...
@@ -71,6 +78,7 @@ fun <E> Iterable<E>.toLockFreeLinkedList(): LockFreeLinkedList<E> {
/**
* 构建链表结构然后转为 [LockFreeLinkedList]
*/
@MiraiInternalAPI
fun
<
E
>
Sequence
<
E
>.
toLockFreeLinkedList
():
LockFreeLinkedList
<
E
>
{
return
LockFreeLinkedList
<
E
>().
apply
{
addAll
(
this
@
toLockFreeLinkedList
)
}
}
...
...
@@ -81,6 +89,8 @@ fun <E> Sequence<E>.toLockFreeLinkedList(): LockFreeLinkedList<E> {
* Modifying can be performed concurrently.
* Iterating concurrency is guaranteed.
*/
@PlannedRemoval
(
"1.0.0"
)
// make internal
@MiraiInternalAPI
(
"This is unstable API and is going to be internal in 1.0.0"
)
open
class
LockFreeLinkedList
<
E
>
{
@PublishedApi
internal
val
tail
:
Tail
<
E
>
=
Tail
()
...
...
mirai-core/src/jvmMain/kotlin/net/mamoe/mirai/event/internal/MiraiAtomicBoolean.kt
View file @
c3de96dd
@
file
:
OptIn
(
MiraiInternalAPI
::
class
)
package
net.mamoe.mirai.event.internal
import
net.mamoe.mirai.event.Event
import
net.mamoe.mirai.event.Listener
import
net.mamoe.mirai.utils.LockFreeLinkedList
import
net.mamoe.mirai.utils.MiraiInternalAPI
import
java.util.concurrent.atomic.AtomicBoolean
import
kotlin.reflect.KClass
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment