pocmatos
2018-10-12 07:55:23

@greg I regularly have this problem when working with racket/base lang. I am writing using racket-mode and do for example (define tmp (make-temporary-file)). Then I run and baamm, racket complains that make-temporary-file is an unbound identifier. Is there a way in racket-mode, with a keypress to adjust my requires so that I have no extra requires or missing requires? There are a few require utilities in racket-mode but none that does this. Am I wrong?


pocmatos
2018-10-12 07:56:50

ok. I understand that it’s not easy to achieve this because many libraries can export the same identifier, but maybe this would be easy to do if the identifier is provided by a racket sublibrary?


pocmatos
2018-10-12 14:06:19

In my implementation of loci, I need to mimic the fact that a place is ready for synchronization when a message is available on the channel. However, the interesting thing here is that the result of synchronization is not the channel, but instead is the message. How is this implemented? Native places seem to be implemented in C so no help there and the version based on threads doesn’t seem to be doing the right thing - but most likely the problem is mine in not understanding #:property prop:evt when a lambda is given. The documentation refers to guard-evt whose documentation I can’t understand. Can someone explain how this works to me? I promise to create a PR to improve the docs once I understand it.


samth
2018-10-12 14:08:38

you might take a look at the Chez implementation of places


pocmatos
2018-10-12 14:10:03

You mean the racket-on-chez implementation of places? is that in racket?




pocmatos
2018-10-12 14:13:50

thanks for the references


samth
2018-10-12 14:17:21

a guard-evt is basically a function that produces an event, and it’s ready when the event produced is ready


ryanc
2018-10-12 14:18:47

@pocmatos you may find the following paper useful for discussing similar issues and how to handle them robustly: https://www.cs.utah.edu/plt/publications/pldi04-ff.pdf


greg
2018-10-12 14:20:00

@pocmatos I empathize. Don’t have much bandwidth right now to think/implement, but, two quick thoughts: 1. You could start a new file with #lang racket, and switch to #lang racket/base using M-x racket-base-requires only after the “edit/churn velocity” of the file settles down. But, not ideal. e.g. Easy to forget to switch it, and, “heavy” during dev when you least want it. 2. I can imagine something that prompts the user to pick the module to require, when ambig, or just adds it when clear. Much like how help search works on http://docs.r-l.org\|docs.r-l.org. But again, don’t have time this week to work on that. (Would welcome a PR, though also not so much time to review a PR right now.)


greg
2018-10-12 14:20:50

TL;DR Understand the need, good feature idea.


pocmatos
2018-10-12 14:23:02

@samth ok, maybe I am missing something then. Need to study the code better. From looking at the code in thread/place.rkt it seems the trick lives in place-channel, prop:evt property.


pocmatos
2018-10-12 14:23:08
  #:property prop:evt (poller (lambda (self poll-ctx)
                                (define in-mq (ephemeron-value (pchannel-in-mq-e self)))
                                (if in-mq
                                    (dequeue! in-mq
                                              (lambda (v)
                                                (values #f
                                                        (wrap-evt
                                                         always-evt
                                                         (lambda (a)
                                                           ;; Convert when out of atomic region
                                                           (un-message-ize v)))))
                                              (lambda (sema)
                                                (values #f (replace-evt sema (lambda (s) self)))))
(values #f never-evt))))

pocmatos
2018-10-12 14:23:21

what’s that poller? it’s not documented.


pocmatos
2018-10-12 14:23:34

@ryanc thanks, will read.


pocmatos
2018-10-12 14:24:19

@greg thanks, lets see if I can get a PR out.


samth
2018-10-12 14:24:49

that code is written against lower layers which aren’t exposed, so not everything is documented


samth
2018-10-12 14:25:04

I can’t remember if poller is written in that layer or in the cs code


ryanc
2018-10-12 14:25:12

looks like the same as unsafe-poller


pocmatos
2018-10-12 14:26:11

ah, that one I can find… quite low level stuff already.


pocmatos
2018-10-12 14:26:47

maybe what I need is related to that replace-evt


pocmatos
2018-10-12 14:30:39

hummm… wrap-evt is also a good candidate! :slightly_smiling_face:


ryanc
2018-10-12 14:41:02

@mflatt in the code above, it seems like messages would get lost when synchronizing on two place channels, since the success case of dequeue! pops a message and puts it in an evt without forcing the scheduler to commit to that evt. (The docs for sync say that if multiple evts are ready (like wrapped always-evts), one is chosen pseudo-randomly.)


mflatt
2018-10-12 14:46:19

@ryanc The poller context is unusual in that returning always-evt means that the event will be selected.


mflatt
2018-10-12 14:46:46

See the poller declaration in “evt.rkt”


ryanc
2018-10-12 14:48:17

ah, thanks


ryanc
2018-10-12 14:50:15

So the first result value is a fast path rather than being the only way of forcing the scheduler to select the current event.


mflatt
2018-10-12 14:50:18

@pocmatos I’m not certain in this case, but I would expect you to be able to do what you want without dropping down to the level of unsafe-poller. Often it’s a matter of using the existing event constructs in the right (but not obvious way). The primitive implementation of place messages has to be that primitive because it’s essentially the primitive implementation of an OS-thread–Racket-thread bridge.


mflatt
2018-10-12 14:50:50

@ryanc Yes. And that fast path doesn’t support running in non-atomic mode.


pocmatos
2018-10-12 14:51:17

Yes, after reading the docs… very slowly… I think I got it! :slightly_smiling_face: Running some tests… thanks.


notjack
2018-10-12 16:59:14

net2 is meant to provide a wrapper to let you send HTTP requests over Unix sockets, tcp sockets, and in-process pipes to other places / threads with the same interface - started work on it and got somewhat far but stalled on it for various non-technical reasons. I hope to get back to it eventually.


notjack
2018-10-12 17:00:14

It’s definitely not in a usable state yet, at least for your purposes