[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet-nim] branch master updated: don't use AsyncEvent bu
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet-nim] branch master updated: don't use AsyncEvent but store Futures in GnunetApplication |
Date: |
Sat, 28 Jul 2018 03:21:06 +0200 |
This is an automated email from the git hooks/post-receive script.
lurchi pushed a commit to branch master
in repository gnunet-nim.
The following commit(s) were added to refs/heads/master by this push:
new 46b3aec don't use AsyncEvent but store Futures in GnunetApplication
46b3aec is described below
commit 46b3aeccf363b82058a7bd4d2b3234013d645fec
Author: lurchi <address@hidden>
AuthorDate: Sat Jul 28 03:20:52 2018 +0200
don't use AsyncEvent but store Futures in GnunetApplication
---
asynccadet.nim | 22 ++++++++--------------
gnunet_application.nim | 4 ++--
2 files changed, 10 insertions(+), 16 deletions(-)
diff --git a/asynccadet.nim b/asynccadet.nim
index 3cffa40..93ad2fd 100644
--- a/asynccadet.nim
+++ b/asynccadet.nim
@@ -50,9 +50,11 @@ proc channelMessageCheckCb(cls: pointer,
proc cadetConnectCb(cls: pointer) {.cdecl.} =
let app = cast[ptr GnunetApplication](cls)
echo "cadetConnectCb"
- var event: AsyncEvent
- if app.connectEvents.take("cadet", event):
- event.trigger()
+ var future: FutureBase
+ if app.connectFutures.take("cadet", future):
+ let cadetHandle = CadetHandle(handle:
GNUNET_CADET_connect(app.configHandle),
+ openPorts: newSeq[ref CadetPort]())
+ Future[CadetHandle](future).complete(cadetHandle)
proc messageHandlers(): array[2, GNUNET_MQ_MessageHandler] =
result = [
@@ -81,17 +83,9 @@ proc sendMessage*(channel: CadetChannel, payload: seq[byte])
=
GNUNET_MQ_send(GNUNET_CADET_get_mq(channel.handle), envelope)
proc connectCadet*(app: ref GnunetApplication): Future[CadetHandle] =
- let future = newFuture[CadetHandle]("connectCadet")
- let event = app.connectEvents.mgetOrPut("cadet", newAsyncEvent())
+ result = newFuture[CadetHandle]("connectCadet")
+ app.connectFutures.add("cadet", result)
discard GNUNET_SCHEDULER_add_now(cadetConnectCb, addr app[])
- proc eventCb(fd: AsyncFd): bool =
- debug("eventCb")
- let cadetHandle = CadetHandle(handle:
GNUNET_CADET_connect(app.configHandle),
- openPorts: newSeq[ref CadetPort]())
- future.complete(cadetHandle)
- true
- addEvent(event, eventCb)
- return future
proc openPort*(handle: var CadetHandle, port: string): ref CadetPort =
var handlers = messageHandlers()
@@ -111,7 +105,7 @@ proc openPort*(handle: var CadetHandle, port: string): ref
CadetPort =
proc closePort*(handle: var CadetHandle, port: ref CadetPort) =
GNUNET_CADET_close_port(port.handle)
- handle.openPorts.delete(handle.openPorts.find(port))
+ handle.openPorts.delete(handle.openPorts.find(port))
proc createChannel*(handle: CadetHandle, peer: string, port: string):
CadetChannel =
var peerIdentity: GNUNET_PeerIdentity
diff --git a/gnunet_application.nim b/gnunet_application.nim
index fd5420a..2af100a 100644
--- a/gnunet_application.nim
+++ b/gnunet_application.nim
@@ -11,7 +11,7 @@ type
schedulerDriver: GNUNET_SCHEDULER_Driver
schedulerHandle: ptr GNUNET_SCHEDULER_Handle
configHandle*: ptr GNUNET_CONFIGURATION_Handle
- connectEvents*: Table[string, AsyncEvent]
+ connectFutures*: Table[string, FutureBase]
proc schedulerAdd(cls: pointer,
task: ptr GNUNET_SCHEDULER_Task,
@@ -67,7 +67,7 @@ proc initGnunetApplication*(configFile: string): ref
GnunetApplication =
set_wakeup: schedulerSetWakeup)
app.schedulerHandle = GNUNET_SCHEDULER_driver_init(addr app.schedulerDriver)
app.configHandle = GNUNET_CONFIGURATION_create()
- app.connectEvents = initTable[string, AsyncEvent]()
+ app.connectFutures = initTable[string, FutureBase]()
assert(GNUNET_SYSERR != GNUNET_CONFIGURATION_load(app.configHandle,
configFile))
return app
--
To stop receiving notification emails like this one, please contact
address@hidden
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] [gnunet-nim] branch master updated: don't use AsyncEvent but store Futures in GnunetApplication,
gnunet <=