For those who wondering why although in c++20 std::atomic already became a standard, your code can't be compile if you write as such: gcc & clang don't implement it except msvc :(
@warrenbuckley32673 жыл бұрын
Damn, I just tested this with GCC 11 and got a static assert that std::atomic requires a trivially copyable type... That sucks..
@sean7235 Жыл бұрын
gcc 12.1 and clang 15 now support this.
@sanjuuyonsai10 жыл бұрын
I was about to write a few lines about how there's a problem with the singly linked list's "push front" and "pop front" not updating p next and p between CAS iterations. But luckily, before posting I checked the docs for "compare exchange weak" and discovered that the first parameter is actually a reference that returns an updated snapshot of "head" in it! :( That's one example where references hide the fact that they may be out-parameters. Anyway, a very good and interesting talk!
@NoNameAtAll24 жыл бұрын
Reference is IN-OUT parameter Const ref is IN parameter
@Astfresser2 жыл бұрын
- What is the progress on the question regarding stack overflow 23:22? It might very well be an actual issue in embedded systems. Also it introduces a failure condition - I would like to know an adequate solution for list remove(item). It seems to be far more complex than the other operations even with shared_ptrs - I also believe that herbs push_front is flawed and races with other push_fronts. The problem is that when two tasks queue up before the CAS and pick up head, both p->next will point to the same node previously stored in head (two atomic_loads will happen beside each other). p->next should be updated within the CAS-loop to consider the other node (who won the race) or this node will lose its pointer right away after the next CAS and get deleted.
@dosomething37 жыл бұрын
48:51 "divider = divider->next; " - but in the ctor we initialized: "divider = Node(T())".
@schulmastery6 жыл бұрын
you forgot the new keyword
@warrenbuckley32673 жыл бұрын
I'm curious if there would be an issue if we returned an aliased shared_ptr from the pop_front member function.
@Jackmccallumlols9 жыл бұрын
Shared Pooter
@seditt51465 жыл бұрын
Dude, I came to the comments only because I knew I could not be the only person that drove nuts as he kept saying it. Is it suppose to be called a putter or something? Is he just calling it 'p' 't' 'r' and sounding it out phonically? What gives because that shit drives me crazy.
@toryvindmoe67944 жыл бұрын
@@seditt5146 it's a shared_ptr. You may want it to be a pointer, but that doesn't make it one.
@93Mosfet2 жыл бұрын
At 38:00 I think is Fedor Pikus asking the question
@jithintc42003 жыл бұрын
@24:24 can reference be null/nullptr ? References aren't pointers right ? Or is it possible for references to be nullptr ?
@ekimr909 жыл бұрын
If a reference being passed into a function isn't const, it's usually safe to assume that it's an output parameter. At least that's my thought on it.
@phillipratzloff89236 жыл бұрын
Herb, if you’re monitoring this I’d like to know how a couple of statements you made turned out. 36:18 "It is an open question, including at the standards meeting on Thursday, whether atomic shared_ptr can be written to be lock-free." Can it be atomic? 36:45 I was given an action item on Thursday, between now and November, to try to go put together a benchmark that actually shows it can be competitive or better ….” Is it competitive (faster)?
@perekman35704 жыл бұрын
The atomic shared_ptr specialization is coming in C++20.
@warrenbuckley32673 жыл бұрын
@@perekman3570 It's been implemented in MSVC but not gcc or clang.
@eiroo51922 жыл бұрын
In the bonus slides (e.g. 49:02) : the consumer releases its "lock" potentially twice. Isn't that inherently unsafe? Isn't it possible that _this_ consumer does it's second release while the lock is effectively already held by the next consumer (that isn't ready for a release yet)? What is it that I don't understand here?
@myname356 Жыл бұрын
Unless I'm missing something, in the line below the first release the function returns already. So you would never release twice in this code.
@origamibulldoser161810 жыл бұрын
Reference counting the entire list? ... So it's lock free, and should scale well, but has a higher baseline from the reference counting?
@dang54023 жыл бұрын
What about double linked lists ? It is so mch hurder I can't even know where to start from.
@sanjuuyonsai9 жыл бұрын
But you don't see that at the calling site, only if you see the called function's signature or documentation.
@GeorgeTsiros6 жыл бұрын
but why is head "shared data"? Doesn't each slist instance get its own head?
@foxtrotromeo48765 жыл бұрын
sure, but one slist instance is used in multiple threads. if two threads call pop or push simultaneous, they both access head through that one instance and hence head is shared between the two threads. here, "shared" is defined as multiple threads using it, not multipe objects or datastructures use it.
@sanjuuyonsai10 жыл бұрын
There you go. After making it look less like sourcecode, the error changed to "too long", and I had to shorten it a bit. Censorship sucks. Especially if it's done automatically with obscure rules.
@sanjuuyonsai10 жыл бұрын
Interesting. I tried posting something but only got "Error, try again"
@vladimir4c4 жыл бұрын
Constructing shared_ptr for each push... the performance would be worse then the lock-based implementation