# Tag Info

0

You have implemented a bathroom that can be occupied by only one type of genital at a time. Therefore it is not a unisex bathroom but a monosex bathroom. You have labelled sex as "man" and "woman" which are genders. From what I understand the terms you are looking for here are "penis" and "vagina". The code only identifies entrants as "men" hile all others ...

0

Method Names Robert C. Martin, who wrote the book "Clean Code", sad Don’t Use a Comment When You Can Use a Function or a Variable In your case you have the function (or method) but you need to clarify what it does with a comment because of the meaningless name of the method. // heuristics in our case - manhattan distance public int h(Vertex s, Vertex ...

0

A few fixes / possible improvements: Scheduler Crash on Exception This is the most significant I've found. The thread responsible for Starting the Pending Task first awaits the Current Task completion, but an exception will abort this continuation, leaving the queue in a hung state. The exception should be caught. if (a.Pending.Acquire()) { try { ...

3

The most expensive operation you're performing is calculating a^(rk) every iteration. Since you are doing this in a loop and increasing the exponent by a constant amount each iteration (k), you can replace the exponentiation with a multiplication. This makes your concurrent task function look like this: go func(receiver chan int64, rGiven, k int64) {...

3

Foreword I appreciate you taking the effort to edit your question time and again to clarify your goal. At first, I thought you were making a synchronous task scheduler using whatever thread is available at any given time, which would have been really cool as well! In fact, your smartly designed API could be augmented to become one if you allow: chaining ...

1

Couple of points on improving the implementation: Line 7: futex_wait doesn't specify FUTEX_WAIT which should be the third argument. syscall(SYS_futex, addr, **FUTEX_WAIT,** block_if_value_is, nullptr, nullptr, 0); You should use FUTEX_WAIT_PRIVATE and FUTEX_WAKE_PRIVATE - more optimal unless you intend to use this mutex for cross-process synchronization. ...

4

Using GNU Parallel you code will look something like this: #!/usr/bin/env bash export script="path_to_python_script" doit() { i="$1" j="$2" $script -args_1 "$i" $script -args_1 "$i" -args_2 value -args_3 value } export -f doit parallel --resume --results data/file_{1}-{2}.txt doit ::: {1..100} ::: {1..100} In your original code if one ...

11

Some suggestions: The trailing slash in the mkdir command is redundant. $(…) is preferred over backticks for command substitution. Why use seq in one command? They both do the same loop, so you might as well use {1..100} in both places. Semicolons are unnecessary in the vast majority of cases. Simply use a newline to achieve the same separation between ... 5 A few observations off the top of my head cerrMutex is unused, and should be removed if not needed. mapMutex is used to guard a static std::map but is itself a regular class member variable. That suggests it probably isn't guarding the map against concurrent access. This is probably a bug. This seems like a fairly heavyweight tool. The uses of maps and ... 0 I think yours works, but async specializes in this stuff. recurseAsync :: (a -> IO [a]) -> a -> IO [a] recurseAsync f a = do xs <- f a fmap concat$ mapConcurrently (recurseAsync f) xs

Top 50 recent answers are included