Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
SquirrelJME
Commits
64519b08
Commit
64519b08
authored
Dec 28, 2019
by
Stephanie Gawroriski
Browse files
Implement register and forwarding of IPC events.
parent
7675c775
Changes
1
Hide whitespace changes
Inline
Side-by-side
runt/apis/cldc-compact/cc/squirreljme/jvm/IPCManager.java
View file @
64519b08
...
...
@@ -9,6 +9,9 @@
package
cc.squirreljme.jvm
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
* This class is used to manage the IPC interface and allow any service to
* register IPC messages and such.
...
...
@@ -17,6 +20,10 @@ package cc.squirreljme.jvm;
*/
public
final
class
IPCManager
{
/** Services that are available. */
private
static
final
Map
<
Integer
,
IPCCallback
>
_IPC_MAP
=
new
HashMap
<>();
/**
* No instances of this class.
*
...
...
@@ -45,7 +52,22 @@ public final class IPCManager
public
static
final
long
ipcCall
(
int
__tid
,
int
__ipcid
,
int
__a
,
int
__b
,
int
__c
,
int
__d
,
int
__e
,
int
__f
,
int
__g
,
int
__h
)
{
throw
new
todo
.
TODO
();
IPCCallback
handler
=
null
;
// Find the IPC Callback handler
Map
<
Integer
,
IPCCallback
>
ipcmap
=
_IPC_MAP
;
synchronized
(
ipcmap
)
{
handler
=
ipcmap
.
get
(
__ipcid
);
}
// Drop the call if there is no handler
if
(
handler
==
null
)
return
0
;
// Perform the call
return
handler
.
ipcCall
(
__tid
,
__ipcid
,
__a
,
__b
,
__c
,
__d
,
__e
,
__f
,
__g
,
__h
);
}
/**
...
...
@@ -53,16 +75,27 @@ public final class IPCManager
*
* @param __ipcid The IPC ID to listen on.
* @param __cb The callback for the IPC.
* @throws IllegalArgumentException If IPC ID is zero.
* @throws NullPointerException On null arguments.
* @since 2019/12/28
*/
public
static
final
void
register
(
int
__ipc
o
d
,
IPCCallback
__cb
)
throws
NullPointerException
public
static
final
void
register
(
int
__ipc
i
d
,
IPCCallback
__cb
)
throws
IllegalArgumentException
,
NullPointerException
{
if
(
__cb
==
null
)
throw
new
NullPointerException
(
"NARG"
);
throw
new
todo
.
TODO
();
// {@squirreljme.error ZZ3u It is not valid to register the zero
// IPC ID.}
if
(
__ipcid
==
0
)
throw
new
IllegalArgumentException
(
"ZZ3u"
);
// Lock and register
Map
<
Integer
,
IPCCallback
>
ipcmap
=
_IPC_MAP
;
synchronized
(
ipcmap
)
{
ipcmap
.
put
(
__ipcid
,
__cb
);
}
}
}
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