Posts made by fatbull
-
RE: Am I the dumb? Why are we rolling our own Destroy logic?
@tsaukpaetra Well, there is your problem. According to the comment, Dequeue is supposed to be called from the consumer thread only. If two threads call Dequeue simultaneously during cleanup, some items could be dequeued twice or one thread could try to dequeue an item from an empty queue or worse.
Next question: What happens if Enqueue and Dequeue run in parallel? How is this synchronized? -
RE: Reading stdout with WinAPI
@deadfast I don't know if it is really allowed to have invalid handles in STARTUPINFO if STARTF_USESTDHANDLES is set, but if it is, you should probably set them to INVALID_HANDLE_VALUE instead of nullptr.
-
RE: Am I the dumb? Why are we rolling our own Destroy logic?
@tsaukpaetra What happens if you call Dequeue() on an empty queue? Who frees the memory after the dtor has been called? It might be a better idea to use InterlockedExchange or an event or a critical section or something similar to synchronize access to that flag.
-
RE: EnumerableExtensions
Disclaimer: I rarely use C#. Use with caution.
public static T FindFirstMinOrDefault<T, S>(this IEnumerable<T> enumerable, Func<T, S> selector) where S : IComparable<S> { return enumerable.Where(x => x != null && selector(x) != null).DefaultIfEmpty() .Aggregate((a, b) => selector(a).CompareTo(selector(b)) <= 0 ? a : b); }
(For FindFirstMaxOrDefault use
>=
instead of<=
.) -
RE: Java regex help
Wait... Doesn't
Replace
search the string again? Why is the searched string modified in the loop? And are the double#
really correct? What does this function actually do? I'm confused now. -
RE: Java regex help
Is
regexVars
shared between requests?
Is a debugger attached which callsfind()
? -
RE: Java regex help
Shouldn't that be
\\P
instead of\P
?
Is there another call tofind
/lookingAt
/matches
/etc. afterfind()
and beforegroup()
?
And why are some spaces around thebackticks
missing in the previous line? -
RE: Spot the bug: javascript queue
Assigning nonexistent would be legal and would result in the destruction of the assignee
var foo = nonexistent;
Filed Under: The var is dead, long live the var!
-
RE: Spot the bug: javascript queue
unless deleted value and undefineded value make semantical difference that actually affects code
Object.prototype[0] = 42; x = [123]; alert(x); x[0] = undefined; alert(x); delete x[0]; alert(x);
Filed Under: My brain hurts!
-
RE: Spot the bug: javascript queue
there's null, and then there's undefined, and then there's "really undefined"
IMHO
undefined
is the JS equivalent of a compile time error. In a senseundefined
is "nuller" thannull
. The property/method/parameter/return value is not only unknown; it doesn't even exist at all. It's not part of the program. -
RE: Spot the bug: javascript queue
Fields that hold undefined and empty fields act differently with reflection and iteration.
... and access. Reading a non-existent property does not necessarily return
undefined
. If the object has a prototype which defines the property, you get that value instead. Arrays are no different in this regard. -
RE: Run-length encoding using SQL
Did you consider using a cursor? Input one row at a time, aggregate in a temp table, output if the value changes.
-
RE: How One Stupid Tweet Blew Up Justine Sacco’s Life (article)
Twitter makes it even easier to fuck up, since you only have 140 characters to work with and have to compress everything down to that.
Now I am become Twitter, destroyer of words.
The views, opinions and positions expressed by the author in this post do not necessarily reflect the views, opinions and positions of the author of this post.
-
RE: Is this C++ code safe?
Well, the idea was to preallocate all state objects and use a pointer to choose the active one. Non-static member variables are probably a better choice.
Filed under: