Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
quasar-wayland
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jens Nolte
quasar-wayland
Commits
f2f5def1
Commit
f2f5def1
authored
3 years ago
by
Jens Nolte
Browse files
Options
Downloads
Patches
Plain Diff
Add send- and receive thread
parent
b4f365e7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
quasar-wayland.cabal
+1
-1
1 addition, 1 deletion
quasar-wayland.cabal
src/Quasar/Wayland/Client.hs
+36
-3
36 additions, 3 deletions
src/Quasar/Wayland/Client.hs
with
37 additions
and
4 deletions
quasar-wayland.cabal
+
1
−
1
View file @
f2f5def1
...
...
@@ -98,7 +98,7 @@ library
template-haskell,
--unix,
--unordered-containers,
--
stm,
stm,
xml,
-- required for record-dot-preprocessor
record-dot-preprocessor,
...
...
This diff is collapsed.
Click to expand it.
src/Quasar/Wayland/Client.hs
+
36
−
3
View file @
f2f5def1
...
...
@@ -3,17 +3,21 @@ module Quasar.Wayland.Client (
newWaylandClient
,
)
where
import
Control.Concurrent.STM
import
Control.Monad.Catch
import
Network.Socket
qualified
as
Socket
import
Network.Socket
(
Socket
)
import
Network.Socket
qualified
as
Socket
import
Network.Socket.ByteString
qualified
as
Socket
import
Quasar
import
Quasar.Prelude
import
Quasar.Wayland.Protocol
import
System.Environment
(
getEnv
,
lookupEnv
)
import
System.FilePath
((
</>
),
isRelative
)
import
Text.Read
(
readEither
)
data
WaylandClient
=
WaylandClient
{
protocolStateVar
::
TVar
ProtocolState
,
socket
::
Socket
,
resourceManager
::
ResourceManager
}
...
...
@@ -26,14 +30,43 @@ instance IsDisposable WaylandClient where
newWaylandClient
::
MonadResourceManager
m
=>
Socket
->
m
WaylandClient
newWaylandClient
socket
=
do
protocolStateVar
<-
liftIO
$
newTVarIO
initialProtocolState
resourceManager
<-
newResourceManager
onResourceManager
resourceManager
do
registerDisposeAction
(
pure
()
<$
Socket
.
close
socket
)
pure
WaylandClient
{
let
client
=
WaylandClient
{
protocolStateVar
,
socket
,
resourceManager
}
registerDisposeAction
$
closeWaylandClient
client
runUnlimitedAsync
do
async
$
liftIO
$
waylandClientSendThread
client
async
$
liftIO
$
waylandClientReceiveThread
client
pure
client
waylandClientSendThread
::
WaylandClient
->
IO
()
waylandClientSendThread
client
=
forever
do
undefined
waylandClientReceiveThread
::
WaylandClient
->
IO
()
waylandClientReceiveThread
client
=
forever
do
bytes
<-
Socket
.
recv
client
.
socket
4096
traceIO
$
"Received data"
atomically
$
modifyTVar
client
.
protocolStateVar
$
feedInput
bytes
state
<-
atomically
$
readTVar
client
.
protocolStateVar
traceIO
$
show
state
.
bytesReceived
closeWaylandClient
::
WaylandClient
->
IO
(
Awaitable
()
)
closeWaylandClient
client
=
isDisposed
<$>
forkTask
do
-- gracefulClose may fail but guarantees that the socket is deallocated
Socket
.
gracefulClose
client
.
socket
2000
`
catch
`
\
(
_
::
SomeException
)
->
pure
()
connectWaylandClient
::
MonadResourceManager
m
=>
m
WaylandClient
connectWaylandClient
=
mask_
do
socket
<-
liftIO
connectWaylandSocket
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment