Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
P
ParaEncode
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Linshizhi
ParaEncode
Commits
b291d6df
Commit
b291d6df
authored
May 16, 2022
by
Linshizhi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add RBLKS, WBLKS field to channel.
parent
77d8fb3f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
258 additions
and
58 deletions
+258
-58
defs.js
resources/workers/defs.js
+219
-42
channel.js
src/channel.js
+39
-16
No files found.
resources/workers/defs.js
View file @
b291d6df
This diff is collapsed.
Click to expand it.
src/channel.js
View file @
b291d6df
...
...
@@ -44,19 +44,26 @@ export class Channel {
* 2.Read Position
*
* Figure:
* ----------------------------------------------------------------------------------------------------------------
* | ReadPointer (4 bytes) | WritePointer (4 Bytes) |
Private (4 Bytes) | WBlocks (2 Bytes) | RBlocks
(2 Bytes) | Data Area (N bytes) |
* ----------------------------------------------------------------------------------------------------------------
* ----------------------------------------------------------------------------------------------------------------
---------------
* | ReadPointer (4 bytes) | WritePointer (4 Bytes) |
RBlks (1 Byte) | WBlks (1 Bytes) | Private
(2 Bytes) | Data Area (N bytes) |
* ----------------------------------------------------------------------------------------------------------------
---------------
*
* where N >= 2
*
* */
#
rFieldPosLen
=
4
;
#
wFieldPosLen
=
4
;
#
priFieldLen
=
4
;
#
numOfMetaField
=
3
;
#
rBlkFieldLen
=
1
;
#
wBlkFieldLen
=
1
;
#
priFieldLen
=
2
;
#
fieldSize
=
0
;
#
rPtrShift
=
0
;
#
wPtrShift
=
this
.
#
rPtrShift
+
this
.
#
rFieldPosLen
;
#
rBlkShift
=
this
.
#
wPtrShift
+
this
.
#
wFieldPosLen
;
#
wBlkShift
=
this
.
#
rBlkShift
+
this
.
#
rBlkFieldLen
;
#
priShift
=
this
.
#
wBlkShift
+
this
.
#
wBlkFieldLen
;
#
metaSize
=
0
;
#
size
=
0
;
#
totalSize
=
0
;
...
...
@@ -86,7 +93,8 @@ export class Channel {
this
.
#
size
=
size
+
1
;
// Init shared memory
this
.
#
metaSize
=
this
.
#
rFieldPosLen
+
this
.
#
wFieldPosLen
+
this
.
#
priFieldLen
;
this
.
#
metaSize
=
this
.
#
rFieldPosLen
+
this
.
#
wFieldPosLen
+
this
.
#
rBlkFieldLen
+
this
.
#
wBlkFieldLen
+
this
.
#
priFieldLen
;
this
.
#
shMem
=
shMem
==
null
?
new
bufferType
(
this
.
#
size
+
this
.
#
metaSize
)
:
shMem
;
this
.
#
view
=
new
DataView
(
this
.
#
shMem
);
...
...
@@ -97,8 +105,8 @@ export class Channel {
// Init readPointer and writePointer to
// the first bytes of data area.
this
.
#
view
.
setUint32
(
0
,
this
.
#
writePointerCache
);
this
.
#
view
.
setUint32
(
4
,
this
.
#
readPointerCache
);
this
.
#
view
.
setUint32
(
this
.
#
wPtrShift
,
this
.
#
writePointerCache
);
this
.
#
view
.
setUint32
(
this
.
#
rPtrShift
,
this
.
#
readPointerCache
);
this
.
#
totalSize
=
this
.
#
metaSize
+
this
.
#
size
;
this
.
#
endPos
=
this
.
#
metaSize
+
this
.
#
size
;
...
...
@@ -107,11 +115,11 @@ export class Channel {
}
#
getReadPointer
()
{
return
this
.
#
view
.
getUint32
(
0
);
return
this
.
#
view
.
getUint32
(
this
.
#
rPtrShift
);
}
#
getWritePointer
()
{
return
this
.
#
view
.
getUint32
(
4
);
return
this
.
#
view
.
getUint32
(
this
.
#
wPtrShift
);
}
metaSize
()
{
...
...
@@ -119,12 +127,12 @@ export class Channel {
}
readPriv
()
{
return
this
.
#
view
.
getUint
32
(
8
);
return
this
.
#
view
.
getUint
16
(
this
.
#
priShift
);
}
writePriv
(
privData
)
{
try
{
this
.
#
view
.
setUint
32
(
8
,
privData
);
this
.
#
view
.
setUint
16
(
this
.
#
priShift
,
privData
);
}
catch
(
error
)
{
if
(
error
instanceof
RangeError
)
return
false
;
...
...
@@ -153,6 +161,22 @@ export class Channel {
this
.
#
mode
=
CHANNEL_MODE
.
BYTE
;
}
getRBlks
()
{
return
this
.
#
view
.
getUint8
(
this
.
#
rBlkShift
);
}
setRBlks
(
num
)
{
this
.
#
view
.
setUint8
(
this
.
#
rBlkShift
,
num
);
}
getWBlks
()
{
return
this
.
#
view
.
getUint8
(
this
.
#
wBlkShift
);
}
setWBlks
(
num
)
{
this
.
#
view
.
setUint8
(
this
.
#
wBlkShift
,
num
);
}
isSetPriv
(
flag
)
{
let
flags
=
this
.
readPriv
();
return
flags
&
flag
;
...
...
@@ -165,7 +189,7 @@ export class Channel {
unsetPriv
(
flag
)
{
let
old
=
this
.
readPriv
();
flag
=
flag
^
0x1111
1111
;
flag
=
flag
^
0x1111
;
this
.
writePriv
(
flag
&
old
);
}
...
...
@@ -277,7 +301,6 @@ export class Channel {
this
.
#
writePointerCache
=
this
.
#
getWritePointer
();
this
.
#
readPointerCache
=
this
.
#
getReadPointer
();
console
.
log
(
this
.
#
readPointerCache
,
this
.
#
writePointerCache
);
if
(
!
this
.
#
isAbleToWrite
(
size
))
{
return
[];
...
...
@@ -366,12 +389,12 @@ export class Channel {
#
writePointerUpdate
(
pos
)
{
this
.
#
writePointerCache
=
pos
;
this
.
#
view
.
setUint32
(
4
,
pos
);
this
.
#
view
.
setUint32
(
this
.
#
wPtrShift
,
pos
);
}
#
readPointerUpdate
(
pos
)
{
this
.
#
readPointerCache
=
pos
;
this
.
#
view
.
setUint32
(
0
,
pos
);
this
.
#
view
.
setUint32
(
this
.
#
rPtrShift
,
pos
);
}
}
...
...
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