« first day (1740 days earlier)      last day (1096 days later) » 

1:05 AM
The reason why I wanted to reduce the compilation time the other day is because I often get this error "is not the pdb file that was used when this precompiled header was created, recreate the precompiled header." I have not been able to figure the exact step I need to get this, but it's quite often, and so rebuilding the pch is a bit annoying.. (Compiler Error C2859)
 
 
12 hours later…
1:15 PM
I need a reminder about the const keyword. First where does it bind (I know it was horribly confusing: const int* const; ) second it is very "viral" - there might be members of a class that do not get changed by the owner but might need to get passed to other objects that will maybe, maybe not change it (in this case: references to resources that get loaded in parallel by a different thread and thus can not be initialized by the owner of the variable but by the loader thread)
 
@salbeira Can you please phrase your question more directly. It isn't clear to me what exactly you are asking.
 
const always binds left. If there's nothing left to the const it will bind right
 
I am not quite sure what it is I am asking myself because it is very much bound to the resource initialization problem I am facing ... basically the "go to way to do things" is to declare everything as const that isn't changed but while owner of object A might not ever change A and thus can declare it as const, maybe the reference to that object needs to ge passed to the worker that initializes the object in the first place ... its is a problem of ordering with multithreading
You can't declare a variable as "const at a later date" which is ... of course logical as at compile time the constantness isn't always given but mutithreaded initialization makes this kind of a headache to me
 
nwp
The obvious solution is to initialize it as top-level const before creating the threads. If you can't do that you have to pass const &s or copies or use mutexes or atomics and manually keep track of the data-race avoidance strategy.
Unfortunately it's a very difficult problem that doesn't have a good solution. Starting out with a strategy in mind helps a lot.
 
Race Conditions aren't really the issue here as much as just code design
Let me try to mash up an example
A BitmapFont uses a Texture to render from and a FontData metainfo that contains all the information about the widths heights and kerning of Glyphs. The BitmapFont ever uses data to render but never changes it, so it can have const Texture &a and const FontData &b as members. The Texture and FontData are owned by a different object as they need to be initialized before the Font itself can be created. These variables though can not be const because ...
... they are loaded off-thread in the form of being a member of an object but being assigned in a tasked lambda
class AssetCollection {
    Texture a;
    FontData b;
    Font c;
    AssetCollection(Loader loader) : c(a,b) {
         loader.deferTextureLoading(a, "filepath");
         loader.deferFontDataLoading(b, "filepath");
    }
};
god damnit chat syntax
 
nwp
1:30 PM
Press CTRL+K to make it render as code.
And you can't mix code and text. Or multiline text and code.
Though this looks like data-race bait. How do you know the loader is done loading?
 
Just tallying the times load was called and the worker just increasing the times it is done loading, if both are equal, all work is done
 
nwp
A std::atomic<const Texture *>a = nullptr; seems reasonable. You can fill it, it's const and it has a check builtin to see if the texture is available.
 
This is all just so I can have a smoothly animated loading screen sigh
 
nwp
And if you're actually waiting for the thing to be done you may as well do const Texture a = [] { Texture t; loader.deferTextureLoading(t, "filepath"); loader.waitUntilDone(); return t; }();.
 
Hmh that would still block the rendering thread I think
 
nwp
1:36 PM
The rendering thread is blocked either way since you're waiting. If you don't want to wait and are happy polling until it's available go the atomic route.
 
Its not as much polling as its just waiting for a signal from the loader that it is done - I wrote up the gist of it here: stackoverflow.com/questions/67096588/…
But the issue stays: Is there some way to make references to objects const in classes that only "use" them while the place where these references come from have them not const?
 
nwp
// Data can be copied without a problem
delete data; // I expect the pointer isn't needed anymore after uploading
This will screw you massively eventually.
 
You can have a const T * pointer to a non-const object. In that case the pointer points to an object that could change, but the pointer indicates that it has no intention of being used to make modifications itself.
 
class Owner {
     Resource owned;
};

class User {
     const Resource &not_owned;
};
 
It's important to understand a const reference or pointer does not mean the object never changes, only that you won't use that reference or pointer to change it.
 
nwp
1:43 PM
@salbeira That just works.
 
As a matter of practicality, prefer const Resource * for class data members. Reference data members are often very problematic.
 
Does the constructor of User need to accept a const reference or can it also accept non-consts?
 
A class with a reference member can't be practically moved, and it is hard to make them reasonabily copyable.
 
nwp
It's also data-race bait, thinking you can access not_owned without issues even though you cannot.
@salbeira It should accept a const & because that makes the class more flexible, but a regular ref will compile as well. You can assign a regular ref to a const &.
 
class User {
    const Resource  &not_owned;
public:
    User(Resource &from_outside) : not_owned(from_outside) {}
};
 
nwp
1:45 PM
That seems strictly worse than using const Resource &from_outside.
 
Yeah stuff that can't be realistically (or rather: not headachingly) located on the stack instead of the heap is giving me headaches a lot but people always say "pointers bad, use references wherever you can" and as such I try to design as much as possible as strict members of objects I create in main and only resort to using a "new" keyword at points where I am very sure stuff is needed at way later dates
Like this:
std::vector<video::Sprite> frames;
			std::vector<double> timings;
			for (int i = 0; i < 8; i++) {
				frames.emplace_back(this->spinner_texture, 16, 16, i * 16, 0, 16, 16);
				timings.emplace_back(0.1);
			}
			this->spinner = new animation::Loop(this->spinner_texture, frames, timings);
 
nwp
It's difficult to tell if this is as good as it gets. Generally new should not be used here, but then terrible libraries like Qt exist that force you to do it.
 
I would love for the spinner to be a member of the asset collection and not a pointer to something on the heap but I would have to pass the timings and frames meta-structure as parameters to the constructor of the asset collection and that collection itself is a member of the application so I would need to pass this to the application constructor
So in the end I would have to create the texture, frame data and timings in the main() function before I finally create the Appliaction as a variable in main
And thats just ... a big "no"
 
nwp
You can also write a wrapper that initializes stuff and then passes it to your actual class.
 
Yeah but ownership then becomes a problem, the objects would be owned by the wrapper and because they actually exist as an lvalue reference by then I wouldn't be able to move ownership to the classes that actually "should" be owners
there is std::move but I dislike putting it into initializer lists
 
nwp
1:56 PM
It's too vague for me to say anything useful. Do you have the code somewhere accessible?
 
As its a few ten thousand lines of code as part of a hobby project mix of game engine and software engineering finger lessons I doubt it would help, but I wanted to put it on github for a while now
Right now I host the git repo on my raspberry pi because when I started the project I needed a quick and easy way to switch between working on my PC and my Laptop in university
But I need to make dinner now so I will first try to put consts wherever I find them to be usable and be back in a bit
 
nwp
The note by François is valid though, avoid const and & members. They break copying and moving which is usually more important to have.
 
Im trying to use system calls like fork wait and kill, but the compiler cant find the functions.
I've included the corrected headers but still it cant recognize them
 
nwp
What error message do you get?
 
implicit declaration of function 'fork'
undefined reference to `fork'
 
nwp
2:10 PM
Did you #include <unistd.h>?
 
yes
 
nwp
Then the first message should not appear.
Are you sure you included it in the file it's complaining about?
 
yes
For some reason, the compiler cant even find <sys/wait.h>
I have just one simple c file with this functions. Using gcc my_file.c gives me these errors
 
@Eminem what OS are you compiling on?
 
3:22 PM
Hello, I have a question regarding poll(). A while back I wrote a simple poll() function that would alert if a given fd was writable to/readable from/dead. In the last week or so, I worked on the code a bit, and now the function doesn't work as expected.
I fixed the 'reading from' problem, but I don't get alerted if a client dies. I've checked the socket revents and the only value I'm getting after the fd dies is 5. In the past I handled socked closes with POLLHUP|POLLERR|POLLNVAL, but now it doesn't seem to work anymore.
Does someone have any idea what could be causing this?
 
Regarding the const keyword on functions:

RETURNTYPE function() const { ... }

just means that "this function doesn't change anything, so it can be called on const objects" right? But the return type is then implicitly also const? cause now my compiler says "can't convert from const _Ty * to GLfloat *" on "return vector.data()"
 
The const modifier only applies to member functions, and it says this function won't change the instance used to call the member function. Basically this* is a const T * pointer.
It isn't clear why you have the error you are showing, it looks like you are trying to return a const T * as a T *. There could be many reasons for that, which may or may not be related to the function being const.
And the solution depends on the cause.
But a const member function doesn't implicitly make the return type const.
 
class Batch {

    void add(stuff); //changes batch
    GLfloat *get_coords() const { return this->coords.data(); }

   private:
        std::vector<GLfloat> coords;
        [...]
};
The compiler says: "Now that you say that get_coords is const, I implicitly turn coords.data() to a const GLfloat *"
But I just do not want to restrict the function that gets the coords to require to have a const float *
 
Since all the members are treated as const in a member function, coords is treated as const. std::vector<T>.data() can only return a const pointer if the vector is const so you get a const GLfloat* in this case. And you can't copy a pointer-to-const to a pointer-to-not-const, so the return is an error. You need the function's return type to be const GLfloat *.
 
Uuuurgh but then all functions that call that function also now need to change the type of the variable T.T
 
3:33 PM
That's why auto is awesome.
auto ptr = batch.get_coords(); would have saved you the trouble.
Provided you never used ptr in a non-const manner. If that is the case, you have a fundamental design problem that needs to be revised.
 
Aye ... probably ... I do not even remember if when I started this project auto was athing
 
Without auto const correctness would require you to make ptr a pointer-to-const anyway, so if you are const correct the change should be transparent. Unless, as mentioned previously, it was being used in a non-const way.
This is one example of why it is usually a good idea to use const when it is possible.
 
btw. we previously said that & members are problematic, but & parameters are OK, right?
 
They are fine and usually recommended over pointers (when practical) for function arguments.
 
I see how using pointers for members for easier copying is advantageous but wouldn't that only be relevant if you want to pass your wrapper by value and not by reference in the first place?
As in:
function(Wrapper a); // needs copy constructor
function(Wrapper &a); //would not and is probably faster to begin with
 
3:44 PM
@salbeira depends on what you're doing... the former can be faster under the right circumstances.
depends on if you're copying or moving too
because pointer indirection has cost as well
 
Would it be wise to also change return types of getters if one uses pointers for members?
 
I can't answer that?
I don't have enough information
like most things the answer is "maybe?"
 
class Font {
    openGL::Texture &bitmap;
public:
    openGL::Texture &get_bitmap();
};
vs
class Font {
    openGL::Texture *bitmap;
public:
    openGL::Texture &get_bitmap() { return *(this->bitmap); }
};
 
depends on the ownership semantics of openGL::Texture?
 
It is definetly not owned by the Font ... or rahter I can not guarantee it
 
3:48 PM
well if that's the complete definition of Font I'd just use a type alias instead
 
No it is most definetly not :-P
 
so C++ is a resource oriented language
if you don't know who owns something that's a major issue
 
It is rather a usability thing ... all about the ability to load stuff in the background
 
given my experience with openGL... that's a dangerous thing to do ;p
you'd be better off with Vulkan/DX12
 
e.g. when the main menu is loaded there are no assets loaded to display the loading screen, so it doesn't make sense to have these assets be loaded by a thread and as such these assets can be directly loaded via constructor: Texture("filepath");

Other times, e.g. when loading a different scene and the loading screen can be presented, I want to have it be:

Texture member_of_something;

Holder(Loader loader) { loader.deferLoading(member_of_something, "filepath"); }
and then flip a flag or have a callback that tells the Scene "done, you can stop displaying the Loading Screen now and transition to the actual scene!"
So in one case it makes sense having the members being const while in the other case they need to be changed by the thread because they were default constructed and are an uninitialized resouce
So the primary issue is basically within the loading thing ... I think ... A lot of time passed when I first rewrote the thing
I know once stuff like the Font had the Texture as a member
But whenever I had two classes that would request the same Font I would load the texture twice
So I wrote a loading system that cached already loaded resources and all things are constructed via asking the loader the give me the resource, cached or freshly loaded
if it was cached it would return the reference of the already loaded instance, if not it would return a default constructed instance and defer the loading to a background worker
But that means that the Font can no longer be the owner of the Texture it itself wants to use
Even though it is highly probable, but not guaranteed, that it is the sole user of that texture
But especially Textures are resources that must not be copied so that when the Texture goes out of scope I can be certain that I can call glDeleteTexture(name);
 
4:19 PM
Or ... completely differently, as a kind of "framework", I thought I do not want to force the user to define an order of operation.

Either they can say "Font("textureFilepath", "fontDatafilepath")", in which case the font owns both loaded resources, or "Font(texture_variable, data_variable)" in which case the font does not own the resources as they were loaded seperately somewhere else
That mishmash of ideas kind of lead to a lot of assumptions I am struggling with now, even though I resolved to the "somewhere else" as the primary way of handling this
 
5:07 PM
@salbeira Sounds like std::shared_ptr is in order then.
 
That or I actually manage to get the whole thing under a singular hat and I can have everything existing on the stack (which would be awesome but unlikely)
But hey at least everything uses const now AND is also compiling so at least I have that going for me
 
In practice you can't have everything on the stack, and you shouldn't try to. Stack space is finite and abusing it easily leads to stack overflow.
Even if we assume the stack was infinite in size, managing the lifetime of objects would be nearly impossible. It could only work with very simple models, and since your model is already complex enough that ownerships are unclear, it is probably not simple enough that you could use this approach.
If you want everything to be simply managed via automatic storage duration, object lifetimes can strictly exists in a first in, last out order
 
5:23 PM
Probably a good idea but I should still probably lock the lifetime of resources to the lifetime of rather large objects like scene management objects as to be sure that everything not needed anymore will definetly be destroyed when I switch these objects
I mean anything I as a single person can create will probably never be large enough that a modern consumer PC can't handle it but I want the software I write to always be good quality so just going the "load everything ever necessary on startup" sounds rather horrifying to me
 
6:22 PM
@sehe u here?
 
6:51 PM
@IrinelIovan I am now
 
Help fix auth server, while is live
Basically
i have 15k connections same time
It basically too much
and mysql conenction drops
i get error
Mysql server has gone away
opening is fail.. because players in queue
this amy is crap
@sehe
maybe this one
 
@IrinelIovan You know, you could be a little less curt about it :)
 
Im not good programming buddy, im just know basics
strict for game
Basically it drops connection with mysql thats all
 
@IrinelIovan I bet it's just the load, and maybe a lack of foresight. But you know. Let's see. Do you pool connections?
 
right now i somehow manage to fix it
 
6:59 PM
I didn't look at that part of the code before.
 
I maded 10 auth cores
with get randomn ports
10 auth old auth
[error] Mysql server has gone away
this is only issue left
 
You're rambling. Maybe if you put together a few sentences, you will get across more information. Regardless, it's weekend here and while I enjoy mental gymnastics, I'm not promising help
 
Well, i might be able to handle for now.
But monday
 
@IrinelIovan [Until the next one pops up, since, you know, this is a scale you never reached before. Like I said:]
yesterday, by sehe
I'm glad that the deadline crisis seems averted. Always be prepared, there will be more surprises, but hopefully no roadblocks
 
i need a good auth server
 
7:01 PM
@IrinelIovan Ah. Luft. That sounds more reasonable already.
 
ahagahgah
btw i dont have paypalk
 
So, I'd say we can look at this, but we need a good stress test to reproduce. I need a database script so I can repro locally, looking at the code in peace and also tweaking mysql configs, perhaps.
 
revolut
 
@IrinelIovan Too bad. Turns out upwork is basically unusable to me.
I do have revolut
 
paypal blocked me
i will pay u revo next
 
7:04 PM
I'd frame that one. It happens a lot to many people
 
I managed, 5k ingame
and still enter
 
7:22 PM
@sehe U can replace amy with anarthal mysql asio ?
 
I can do anything. If it's using a Turing complete language. Am I motivated? Nah. I don't think that's the right course of action in your launch weekend. Instead, look at the root of your problem and attacck that
31 mins ago, by sehe
@IrinelIovan I bet it's just the load, and maybe a lack of foresight. But you know. Let's see. Do you pool connections?
@IrinelIovan so I guess it means you don't pool connections? And now you just run 10 auth cores in a pool instead?
 
8:06 PM
No there's no pool.
Now, i just have 10 auth cores
auth process
with 10 different ports
and in client plauyers
i use getRandom to select a random auth from that 10
 
Hello, I have a question regarding poll(). A while back I wrote a simple poll() function that would alert if a given fd was writable to/readable from/dead. In the last week or so, I worked on the code a bit, and now the function doesn't work as expected.
I fixed the 'reading from' problem, but I don't get alerted if a client dies. I've checked the socket revents and the only value I'm getting after the fd dies is 5. In the past I handled socked closes with POLLHUP|POLLERR|POLLNVAL, but now it doesn't seem to work anymore.
 
@IrinelIovan so that's pooling auth servers wholesale and then loadbalancing
 
8:30 PM
Oh
it's like a multitreading
?
When 250 connections, move to new thread and so
 
9:20 PM
Nah. You wouldn't do it like that, but yeah, this is a poor man's load balancer. (the 10 auth servers)
 
9:37 PM
Given a cylinder defined with an origin point, axis vector, height and radius, what will be the most efficient way to determine if a given point P is inside the cylinder?
Ive found this https://www.flipcode.com/archives/Fast_Point-In-Cylinder_Test.shtml
but im not sure if I understand the algorithm
 
You ... just check that it's in the range for the height and then whether it's in the circle for plane intersecting the cylinder and containing the point.
Real problem is "cylinder defined with an origin point, axis vector, height and radius" defines zillions of different cilinders.
You need orientation information
 
hmmm... Are you sure?
Origin and axis vector isnt enough?
 
Ah. The axis is a vector. I missed that
Yeah that'll work. The linked code seems apt
 
But the problem is that in the link the cylinder is not defined in this way
The author uses two points and a radius
 
Just calculate the points? Origin is one.
 
9:44 PM
The first thing that came to my mind is to check the distance between the test point and the line segment using the origin the direction vector. The problem arises if, say the point is directly "beneeth" the cylinder
So the distance is smaller than the radius, but the point is outside
Also, calculating the points will cost me more.
 
10:37 PM
Hello, I have a question regarding poll(). A while back I wrote a simple poll() function that would alert if a given fd was writable to/readable from/dead. In the last week or so, I worked on the code a bit, and now the function doesn't work as expected.
I fixed the 'reading from' problem, but I don't get alerted if a client dies. I've checked the socket revents and the only value I'm getting after the fd dies is 5. In the past I handled socked closes with POLLHUP|POLLERR|POLLNVAL, but now it doesn't seem to work anymore.
Please
 
11:33 PM
@LeonKunštek I think this needs a SO_KEEPALIVE and even then detection is best effort
No idea about the details that you mention. It's been a long time since I dealt with raw poll
 

« first day (1740 days earlier)      last day (1096 days later) »