which languages have a way to wait on 2 or more things at the same time?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
suppose i want to do a group wait that includes waiting for signal SIGUSR2. the signal will be sent by another process to this process. how can the child process be made to wait on a signal sent to its parent ... in each language?
i have reluctance to use more processes. maybe threads can be used? a process just uses more resources. this should have been designed better, such as a way to associate other waits with a file descriptor so select or poll can be used (making it easier for other language implementations to do without the weight of a process for each wait).
If you are trying to move away from C, try Perl.
It can do that sort of stuff; you just need to decide which method to use.
For in-depth answers & options, try perlmonks.org; that's where the gurus hangout.
i want to have it be done in any language, using ones that now do it serving as examples. how would you express on signal SIGUSR2 when preparing to do a group wait?
is it possible for libevent to just return an event rather than do a callback?
You'd have to read the docs, but from what I read it sounds like libevent is based around callbacks, so likely, no. I've never used it myself, I only know its out there.
Like I said, you should ask the guys over at perlmonks.org.
Perl can definitely do what you need in terms of objectives, but (like any other language) there is definitely more than one way to do it.
There are in fact many modules related to process & event handing and communications; it's a qn of choosing the best one(s) for your particular job.
The Perl docs are here https://perldoc.perl.org/ and the modules here https://www.cpan.org/modules/index.html.
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,818
Rep:
Quote:
Originally Posted by Skaperen
which languages have a way to wait on 2 or more things at the same time.
Some folks have already pointed out that many languages have this. I'm not sure if I'd attribute this ability to any programming language but an operating system feature that a language can get access to via some library calls.
Quote:
easily, without doing programming tricks?
IMHO, doing something like this is already a bit of a programming trick. (First encountered while writing FORTRAN programs on PDP-11s running RSX-11M -- event flags, ASTs/traps, etc. were de rigeur when interfacing with lab devices -- so the idea has been around under different names for quite a while. After working with those for a while, those "programming tricks" become second nature.)
what i want to have in a language is some kind of value instance of some class representing all possible things to wait for that can be put in a collective (in Python, maybe a frozenset) to pass to the wait call. in C i have done many kinds of waits, but there were many ways they were coded. higher level languages are where this should be smoothed out to hide the details few programs need to know about.
i need to wait on the reference object returned by foobar() and also one passed to this function in argument thing.
so, asyncio has a way to wait for signals, and everything else? i'm wondering if Python is the language to go with. it would be nice if so.
you still did not specify what do you want to achieve, therefore nobody knows the answer. All high level languages can handle signals and [almost] everything else.
You might be better to take a step back from this requirement – this is one area where different operating systems vary substantially – and look for some kind of "workload manager infrastructure" into which you can then hang your application, waiting on a provided serial queue of incoming events.
You might be better to take a step back from this requirement – this is one area where different operating systems vary substantially – and look for some kind of "workload manager infrastructure" into which you can then hang your application, waiting on a provided serial queue of incoming events.
even if it is not part of a language, if such a thing (workload manager infrastructure) exists, it would be for some language (or a few) to model the concept. if it exists, i wanted to know for which language(s). so, perhaps, it does not exist in such a form.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.