Added support to clear/close the underlying queue implementation
This commit is contained in:
parent
7d6424bc11
commit
8cfb08d63d
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2020 dorkbox, llc
|
* Copyright 2023 dorkbox, llc
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -45,4 +45,10 @@ interface Pool<T> {
|
||||||
* @return a new object instance created by the pool.
|
* @return a new object instance created by the pool.
|
||||||
*/
|
*/
|
||||||
fun newInstance(): T
|
fun newInstance(): T
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the underlying queue implementation
|
||||||
|
*/
|
||||||
|
fun close()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2020 dorkbox, llc
|
* Copyright 2023 dorkbox, llc
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -43,4 +43,9 @@ interface SuspendingPool<T> {
|
||||||
* @return a new object instance created by the pool.
|
* @return a new object instance created by the pool.
|
||||||
*/
|
*/
|
||||||
suspend fun newInstance(): T
|
suspend fun newInstance(): T
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes the underlying implementation
|
||||||
|
*/
|
||||||
|
fun close()
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2020 dorkbox, llc
|
* Copyright 2023 dorkbox, llc
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -79,4 +79,11 @@ internal class BlockingPool<T> constructor(
|
||||||
override fun newInstance(): T {
|
override fun newInstance(): T {
|
||||||
return poolObject.newInstance()
|
return poolObject.newInstance()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the underlying queue implementation
|
||||||
|
*/
|
||||||
|
override fun close() {
|
||||||
|
queue.clear()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2020 dorkbox, llc
|
* Copyright 2023 dorkbox, llc
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -73,4 +73,11 @@ internal class BlockingPoolCollection<T> constructor(
|
||||||
override fun newInstance(): T {
|
override fun newInstance(): T {
|
||||||
return dummyValue
|
return dummyValue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the underlying queue implementation
|
||||||
|
*/
|
||||||
|
override fun close() {
|
||||||
|
queue.clear()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2020 dorkbox, llc
|
* Copyright 2023 dorkbox, llc
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -67,4 +67,11 @@ internal open class NonBlockingPool<T>(
|
||||||
override fun newInstance(): T {
|
override fun newInstance(): T {
|
||||||
return poolObject.newInstance()
|
return poolObject.newInstance()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the underlying queue implementation
|
||||||
|
*/
|
||||||
|
override fun close() {
|
||||||
|
queue.clear()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2020 dorkbox, llc
|
* Copyright 2023 dorkbox, llc
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -77,4 +77,11 @@ internal class NonBlockingSoftPool<T>(
|
||||||
override fun newInstance(): T {
|
override fun newInstance(): T {
|
||||||
return poolObject.newInstance()
|
return poolObject.newInstance()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears the underlying queue implementation
|
||||||
|
*/
|
||||||
|
override fun close() {
|
||||||
|
queue.clear()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2022 dorkbox, llc
|
* Copyright 2023 dorkbox, llc
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -55,4 +55,8 @@ class ChannelQueue<E>(size: Int): SuspendingQueue<E> {
|
||||||
override suspend fun take(): E {
|
override suspend fun take(): E {
|
||||||
return channel.receive()
|
return channel.receive()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun close() {
|
||||||
|
channel.close()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2020 dorkbox, llc
|
* Copyright 2023 dorkbox, llc
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -82,4 +82,11 @@ internal class SuspendingPool<T> constructor(
|
||||||
override suspend fun newInstance(): T {
|
override suspend fun newInstance(): T {
|
||||||
return poolObject.newInstance()
|
return poolObject.newInstance()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes the supporting queue implementation
|
||||||
|
*/
|
||||||
|
override fun close() {
|
||||||
|
queue.close()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2020 dorkbox, llc
|
* Copyright 2023 dorkbox, llc
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -74,4 +74,11 @@ internal class SuspendingPoolCollection<T> constructor(
|
||||||
override suspend fun newInstance(): T {
|
override suspend fun newInstance(): T {
|
||||||
return dummyValue
|
return dummyValue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes the underlying queue implementation
|
||||||
|
*/
|
||||||
|
override fun close() {
|
||||||
|
queue.close()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2022 dorkbox, llc
|
* Copyright 2023 dorkbox, llc
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -89,4 +89,9 @@ interface SuspendingQueue<E> {
|
||||||
* @return the head of this queue, or {@code null} if this queue is empty
|
* @return the head of this queue, or {@code null} if this queue is empty
|
||||||
*/
|
*/
|
||||||
fun poll(): E?
|
fun poll(): E?
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Closes the underlying implementation
|
||||||
|
*/
|
||||||
|
fun close()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue