summary refs log tree commit diff stats
path: root/tests/async/tgeneric_async.nim
blob: bab2d1a31b62870f811cbc658e60cc071ac790e9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
discard """
output: "1\nmessa"
"""

import async

# bug #2377
proc test[T](v: T) {.async.} =
  echo $v

asyncCheck test[int](1)

# More complex case involving typedesc and static params
type
  SomeMsg = object
    data: string

template msgId(M: type SomeMsg): int = 1

proc recvMsg(): Future[tuple[msgId: int, msgData: string]] {.async.} =
  return (1, "message")

proc read(data: string, T: type SomeMsg, maxBytes: int): T =
  result.data = data[0 ..< min(data.len, maxBytes)]

proc nextMsg*(MsgType: typedesc,
              maxBytes: static[int]): Future[MsgType] {.async.} =
  const wantedId = MsgType.msgId

  while true:
    var (nextMsgId, nextMsgData) = await recvMsg()
    if nextMsgId == wantedId:
      return nextMsgData.read(MsgType, maxBytes)

proc main {.async.} =
  let msg = await nextMsg(SomeMsg, 5)
  echo msg.data

asyncCheck main()
18 19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57








                                                                                 
                                                                           

 
               
 
                                                               

                                                                                 

                                                                
                                                                           

 
            
 
                                                                          

                                                          
                                                                     
                                                                  
                                                    
                                                                    
                                                
                                                       




                                                 
                                                  



                                                                        
                                                                        

                                                       
                                                                          
                                         


                                                                    





                                                                             
Required for next Release

   (X) #5   09/07/17  avoid using shell calls, it results in many problems
               can't answer questions of spawned processes
               specifically rm with write-protected files
   (X) #8   09/07/17  Clear keybuffer after executing programs.
               you may have typed something after the program stopped reading
               this could flush the text to ranger and result in unwanted actions
   (X) #14  09/07/18  Sorting sometimes doesn't work
   (X) #17  09/07/19  shell behaves strangely sometimes when run with s key


Critical Issues

   (X) #8   09/07/17  Clear keybuffer after executing programs.
               you may have typed something after the program stopped reading
               this could flush the text to ranger and result in unwanted actions
   ( ) #15  09/07/18  it's way too slow in large directories
               redesign process of getting data from file system
   (X) #17  09/07/19  shell behaves strangely sometimes when run with s key


Minor Issues

   (X) #5   09/07/17  avoid using shell calls, it results in many problems
               can't answer questions of spawned processes
               specifically rm with write-protected files
   (X) #12  09/07/17  sync @marked with changes in on the file system
               if files are deleted, delete those from @marked too
   (X) #14  09/07/18  Sorting sometimes doesn't work
   (X) #16  09/07/19  incorrect pointer in the columns after sorting
   ( ) #18  09/07/19  abbreviate path at the top
   (X) #23  09/07/19  key combination rAr does not work


Features

   ( ) #1   09/07/17  undo key (work in progress)
   ( ) #2   09/07/17  throbber that shows activity
   ( ) #3   09/07/17  colors and attributes in help
   ( ) #6   09/07/17  allow use of sudo somehow
   ( ) #7   09/07/17  allow to change rights and owners easily
   ( ) #9   09/07/17  build an abstract layer for file system operations
               this would encourage the addition of ftp or ssh protocols
   ( ) #11  09/07/17  specify flags at data/types.rb
   ( ) #13  09/07/17  special keys for quick navigation
               cycle in a certain order, like creation-time, newest first.
   ( ) #19  09/07/19  make path clickable
   ( ) #20  09/07/19  accelerate mouse wheel scrolling after a while
   ( ) #21  09/07/19  what about a CONSOLE
   ( ) #22  09/07/19  tab-completition for filenames


Aesthetics

   ( ) #4   09/07/17  consider using optparse
   ( ) #10  09/07/17  Debug module as an IO stream, for redirection of STDERR