Skip to content

Commit

Permalink
refactor(*): refactor epoll constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaultBee committed Jun 28, 2024
1 parent 2415720 commit a3df842
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions srtdroid/src/main/cpp/glue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ nativeEpollIsValid(JNIEnv *env, jobject epoll) {
return static_cast<jboolean>(eid != -1);
}

jint JNICALL
static jint JNICALL
nativeEpollCreate(JNIEnv *env, jobject epoll) {
return srt_epoll_create();
}
Expand Down Expand Up @@ -911,8 +911,8 @@ static JNINativeMethod timeMethods[] = {
};

static JNINativeMethod epollMethods[] = {
{"nativeCreate", "()I", (void *) &nativeEpollCreate},
{"nativeIsValid", "()Z", (void *) &nativeEpollIsValid},
{"create", "()I", (void *) &nativeEpollCreate},
{"nativeAddUSock", "(L" SOCKET_CLASS ";L" LIST_CLASS ";)I", (void *) &nativeEpollAddUSock},
{"nativeUpdateUSock", "(L" SOCKET_CLASS ";L" LIST_CLASS ";)I", (void *) &nativeEpollUpdateUSock},
{"nativeRemoveUSock", "(L" SOCKET_CLASS ";)I", (void *) &nativeEpollRemoveUSock},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,21 @@ import java.security.InvalidParameterException
*
* **See Also:** [Asynchronous operations (epoll)](https://github.com/Haivision/srt/blob/master/docs/API/API-functions.md#asynchronous-operations-epoll-1)
*/
class Epoll {
class Epoll
private constructor(private val eid: Int) {
companion object {
@JvmStatic
private external fun nativeCreate(): Int

init {
Srt.startUp()
}
}

private var eid: Int

init {
eid = create()
}

private external fun create(): Int
/**
* Creates an epoll container.
*/
constructor() : this(nativeCreate())

private external fun nativeIsValid(): Boolean

Expand Down

0 comments on commit a3df842

Please sign in to comment.