lithium icon indicating copy to clipboard operation
lithium copied to clipboard

Support Windows

Open ghost opened this issue 4 years ago • 16 comments

It would lift the library to the next level.

Windows Server 2019 is perfectly capable for server programs!

ghost avatar Jul 19 '20 09:07 ghost

Hi @FastInvite2k2 ,

This is something we can investigate. I don't know much about the windows networking and async IO API but I can have a look. The only part that requires a rewrite for windows is the async TCP server, and it's seems possible reading this:

  • https://stackoverflow.com/questions/67082/what-is-the-best-epoll-kqueue-select-equvalient-on-windows.
  • https://cfsamsonbooks.gitbook.io/epoll-kqueue-iocp-explained/appendix-1/iocp

If anyone has experience with windows network programming, help is welcome!

matt-42 avatar Jul 19 '20 12:07 matt-42

You could add support for libuv and have async I/O for all relevant platforms!

ghost avatar Jul 19 '20 16:07 ghost

Does it already function via WSL2?

alystair avatar Aug 29 '20 15:08 alystair

I never tried but it should no? Is there any program running on linux that does not run under WSL2 ?

matt-42 avatar Aug 29 '20 16:08 matt-42

I'm curious if li::sql has been tested under Windows. I like the look of the API.

frithrah avatar Sep 05 '20 22:09 frithrah

It used to be but not anymore (I guess few compilation errors has to be solved first). Several people asked for windows/macos support so I'll set this as my priority.

matt-42 avatar Sep 07 '20 08:09 matt-42

I wonder if this might help speed up a windows port? https://github.com/piscisaureus/wepoll

"This library implements the epoll API for Windows applications. It is fast and scalable, and it closely resembles the API and behavior of Linux' epoll."

ckaminski avatar Sep 26 '20 18:09 ckaminski

Thanks @ckaminski this looks great. I think use wepoll to quickly get windows support.

matt-42 avatar Sep 28 '20 22:09 matt-42

I started working on it but it seems like there is a bug in the MSVC compiler. The following code fails to compile and I can't find any workaround:

template <typename... Ms> struct metamap;
template <typename M1, typename... Ms> struct metamap<M1, Ms...> : public M1, Ms... {
    metamap(typename M1::test_type&& m, typename Ms::test_type&&... x) {}
};

int main() {}
example.cpp

<source>(14): error C3543: 'metamap<M1,Ms...>::Ms::test_type &&': does not contain a parameter pack

<source>(15): note: see reference to class template instantiation 'metamap<M1,Ms...>' being compiled

Compiler returned: 2

I sent a bug report hope they will fix it pretty soon... https://developercommunity.visualstudio.com/content/problem/1203865/c-compilation-bug-parameter-pack-in-constructor-wi.html

matt-42 avatar Sep 29 '20 12:09 matt-42

Since we'll probably have to wait for quite some time for the MSVC bug to get fixed. I'll delay windows support to an future release.

matt-42 avatar Oct 08 '20 18:10 matt-42

The following workaround seems to compile, tested using Compiler Explorer:

template <typename... Ms> struct metamap;
template <typename M1, typename... Ms> struct metamap<M1, Ms...> : public M1, Ms... {
    template <typename M>
    using TestType = typename M::test_type;

    metamap(TestType<M1>&& m, TestType<Ms>&&... x);
};

int main() {}

chausner avatar Feb 28 '21 22:02 chausner

Thanks @chausner ! Seems like this unblock the progress on the windows support.

matt-42 avatar Mar 01 '21 10:03 matt-42

Would you use boost::asio as the network backend for cross platform?

testmana2 avatar Apr 16 '21 02:04 testmana2

Would you use boost::asio as the network backend for cross platform?

Although would make things somewhat "easier", it also carries a lot of baggage, it has many issues on its own, and being honest, I think lithium is great exactly because of that lack of baggage, it just adds the dependencies that are absolutely needed for doing what it does, and nothing more, which in part is what contributes to its success.

I support doing things adaptive instead of prescriptive, implement just what you need and nothing more, rather than including a library or framework and working around shoehorning the app into such dependencies.

raul-guerrero avatar Apr 16 '21 03:04 raul-guerrero

template<class M> struct m_traits { using iod_value_type = typename M::_iod_value_type; };

constexpr inline metamap(typename m_traits<M1>::iod_value_type &&m1, typename m_traits<Ms>::iod_value_type &&... members) : M1{m1}, Ms{std::forward<typename m_traits<Ms>::iod_value_type>(members)}... {} constexpr inline metamap(M1 && m1, Ms && ... members) : M1(m1), Ms(std::forward<Ms>(members))... {} constexpr inline metamap(const M1 & m1, const Ms & ... members) : M1(m1), Ms((members))... {}

        // Assignemnt ?

        // Retrive a value.
        template <typename K> constexpr decltype(auto) operator[](K k) {
        return symbol_member_access(*this, k);
    }

fix windows build template error

vanehu avatar Dec 22 '21 09:12 vanehu

Thanks @vanehu the master branch now compile on windows but there is still bugs. I'll work more on this later.

matt-42 avatar Feb 07 '22 23:02 matt-42